3 * Copyright 2003,2005 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
24 * mathematical odds and ends.
30 #include <gr_complex.h>
32 long gr_gcd (long m, long n);
34 // returns a non-zero value if value is "not-a-number" (NaN), and 0 otherwise
35 int gr_isnan (double value);
37 // returns a non-zero value if the value of x has its sign bit set.
39 // This is not the same as `x < 0.0', because IEEE 754 floating point
40 // allows zero to be signed. The comparison `-0.0 < 0.0' is false, but
41 // `gr_signbit (-0.0)' will return a nonzero value.
43 int gr_signbit (double x);
46 * \brief Fast arc tangent using table lookup and linear interpolation
48 * \param y component of input vector
49 * \param x component of input vector
50 * \returns float angle angle of vector (x, y) in radians
52 * This function calculates the angle of the vector (x,y) based on a
53 * table lookup and linear interpolation. The table uses a 256 point
54 * table covering -45 to +45 degrees and uses symetry to determine the
55 * final angle value in the range of -180 to 180 degrees. Note that
56 * this function uses the small angle approximation for values close
57 * to zero. This routine calculates the arc tangent with an average
58 * error of +/- 0.045 degrees.
60 float gr_fast_atan2f(float y, float x);
62 static inline float gr_fast_atan2f(gr_complex z)
64 return gr_fast_atan2f(z.imag(), z.real());
68 /* This bounds x by +/- clip without a branch */
70 static inline float gr_branchless_clip(float x, float clip)
72 float x1 = fabsf(x+clip);
73 float x2 = fabsf(x-clip);
80 #endif /* _GR_MATH_H_ */