Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_math.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2003,2005 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
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 2, or (at your option)
10  * any later version.
11  * 
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.
16  * 
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.
21  */
22
23 /*
24  * mathematical odds and ends.
25  */
26
27 #ifndef _GR_MATH_H_
28 #define _GR_MATH_H_
29
30 long gr_gcd (long m, long n);
31
32 // returns a non-zero value if value is "not-a-number" (NaN), and 0 otherwise
33 int gr_isnan (double value);
34
35 // returns a non-zero value if the value of x has its sign bit set.
36 //
37 // This  is  not  the  same  as `x < 0.0', because IEEE 754 floating point
38 // allows zero to be signed.  The comparison `-0.0 < 0.0'  is  false,  but
39 // `gr_signbit (-0.0)' will return a nonzero value.
40
41 int gr_signbit (double x);
42   
43 /*!
44  * \brief Fast arc tangent using table lookup and linear interpolation
45  *
46  * \param y component of input vector
47  * \param x component of input vector
48  * \returns float angle angle of vector (x, y) in radians
49  *
50  * This function calculates the angle of the vector (x,y) based on a
51  * table lookup and linear interpolation. The table uses a 256 point
52  * table covering -45 to +45 degrees and uses symetry to determine the
53  * final angle value in the range of -180 to 180 degrees. Note that
54  * this function uses the small angle approximation for values close
55  * to zero. This routine calculates the arc tangent with an average
56  * error of +/- 0.045 degrees.
57  */
58 float gr_fast_atan2f(float y, float x);
59
60 #endif /* _GR_MATH_H_ */