]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/fastrig.h
ae8485b7c10a85bbe35b94c8bdd8eb3138d80beb
[dttsp.git] / jDttSP / fastrig.h
1 /* fastrig.h
2 This file is part of a program that implements a Software-Defined Radio.
3
4 Copyright (C) 2004 by Frank Brickle, AB2KT and Bob McGwier, N4HY
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20 The authors can be reached by email at
21
22 ab2kt@arrl.net
23 or
24 rwmcgwier@comcast.net
25
26 or by paper mail at
27
28 The DTTS Microwave Society
29 6 Kathleen Place
30 Bridgewater, NJ 08807
31 */
32
33 #ifndef _fastrig_h
34 #define _fastrig_h
35
36 #include <fromsys.h>
37 #include <banal.h>
38 #include <splitfields.h>
39 #include <datatypes.h>
40 #include <bufvec.h>
41 #include <cxops.h>
42
43 #define SIN_TABLE_SIZE 4096
44 #define SIN_TABLE_SIZE_M1 4095
45
46 /* ********************************************** 
47  * TRIG_SPEED: 
48  * 0 = normal (slow); 
49  * 1 = table look up with interpolation (medium);
50  * 2 = table look up (fast) 
51  * ***********************************************/
52
53 /* Interpolation is ALWAYS done on atan2.  The setting
54    only applies to sin and cos */
55
56 #ifndef TRIG_SPEED
57 #define TRIG_SPEED 0
58 #endif
59
60 #if (TRIG_SPEED == 2)
61 #define SIN(x)     fast_sin(x)
62 #define COS(x)     fast_cos(x)
63 #define ATAN2(x,y) fast_atan2((x),(y))
64
65 #elif (TRIG_SPEED == 1)
66
67 #define SIN(x)     fast_sin(x)
68 #define COS(x)     fast_cos(x)
69 #define ATAN2(x,y) fast_atan2((x),(y))
70
71 #elif (TRIG_SPEED == 0)
72
73 #define SIN(x)     (REAL)sin((REAL)x)
74 #define COS(x)     (REAL)cos((REAL)x)
75 #define ATAN2(x,y) (REAL)atan2((REAL)(x),(REAL)(y))
76
77 #endif
78
79 #ifndef PI
80 #define PI M_PI
81 #endif /* PI */
82
83 #ifndef TWOPI
84 #define TWOPI    (2.0 * PI)
85 #endif
86
87 #ifndef ONE_OVER_TWOPI
88 #define ONE_OVER_TWOPI (0.159154943091895)
89 #endif
90
91 #if (TRIG_SPEED != 0)
92
93 extern void InitSPEEDTRIG(void);
94 extern REAL fast_sin(REAL);
95 extern REAL fast_cos(REAL);
96 extern REAL fast_atan2(REAL, REAL);
97
98 #endif
99 #endif