diff options
Diffstat (limited to 'gnuradio-core/src/lib/general/gr_math.h')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_math.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/general/gr_math.h b/gnuradio-core/src/lib/general/gr_math.h index 439e5f4b9..2cd5b8eb7 100644 --- a/gnuradio-core/src/lib/general/gr_math.h +++ b/gnuradio-core/src/lib/general/gr_math.h @@ -64,4 +64,17 @@ static inline float gr_fast_atan2f(gr_complex z) return gr_fast_atan2f(z.imag(), z.real()); } + +/* This bounds x by +/- clip without a branch */ + +static inline float gr_branchless_clip(float x, float clip) +{ + float x1 = fabsf(x+clip); + float x2 = fabsf(x-clip); + x1 -= x2; + return 0.5*x1; +} + + + #endif /* _GR_MATH_H_ */ |