1 | #ifndef TRIGTBL_H_SEEN
|
---|
2 | #define TRIGTBL_H_SEEN
|
---|
3 |
|
---|
4 | /*
|
---|
5 | ** Please only distribute this with it's associated FHT routine.
|
---|
6 | ** This algorithm is apparently patented(!) and the code copyrighted.
|
---|
7 | ** See the comment with the fht routine for more info.
|
---|
8 | ** -Thanks,
|
---|
9 | ** Ron Mayer
|
---|
10 | */
|
---|
11 |
|
---|
12 | #ifdef REAL
|
---|
13 | #else
|
---|
14 | #define REAL double
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #ifdef GOOD_TRIG
|
---|
18 | #else
|
---|
19 | #define FAST_TRIG
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | #if defined(GOOD_TRIG)
|
---|
23 | #define FHT_SWAP(a,b,t) {(t)=(a);(a)=(b);(b)=(t);}
|
---|
24 | #define TRIG_VARS \
|
---|
25 | int t_lam=0;
|
---|
26 | #define TRIG_INIT(k,c,s) \
|
---|
27 | { \
|
---|
28 | int i; \
|
---|
29 | for (i=2 ; i<=k ; i++) \
|
---|
30 | {coswrk[i]=costab[i];sinwrk[i]=sintab[i];} \
|
---|
31 | t_lam = 0; \
|
---|
32 | c = 1; \
|
---|
33 | s = 0; \
|
---|
34 | }
|
---|
35 | #define TRIG_NEXT(k,c,s) \
|
---|
36 | { \
|
---|
37 | int i,j; \
|
---|
38 | (t_lam)++; \
|
---|
39 | for (i=0 ; !((1<<i)&t_lam) ; i++); \
|
---|
40 | i = k-i; \
|
---|
41 | s = sinwrk[i]; \
|
---|
42 | c = coswrk[i]; \
|
---|
43 | if (i>1) \
|
---|
44 | { \
|
---|
45 | for (j=k-i+2 ; (1<<j)&t_lam ; j++); \
|
---|
46 | j = k - j; \
|
---|
47 | sinwrk[i] = halsec[i] * (sinwrk[i-1] + sinwrk[j]); \
|
---|
48 | coswrk[i] = halsec[i] * (coswrk[i-1] + coswrk[j]); \
|
---|
49 | } \
|
---|
50 | }
|
---|
51 | #define TRIG_RESET(k,c,s)
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | #if defined(FAST_TRIG)
|
---|
55 | #define TRIG_VARS \
|
---|
56 | REAL t_c,t_s;
|
---|
57 | #define TRIG_INIT(k,c,s) \
|
---|
58 | { \
|
---|
59 | t_c = costab[k]; \
|
---|
60 | t_s = sintab[k]; \
|
---|
61 | c = 1; \
|
---|
62 | s = 0; \
|
---|
63 | }
|
---|
64 | #define TRIG_NEXT(k,c,s) \
|
---|
65 | { \
|
---|
66 | REAL t = c; \
|
---|
67 | c = t*t_c - s*t_s; \
|
---|
68 | s = t*t_s + s*t_c; \
|
---|
69 | }
|
---|
70 | #define TRIG_RESET(k,c,s)
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | static REAL halsec[20]=
|
---|
74 | {
|
---|
75 | 0,
|
---|
76 | 0,
|
---|
77 | .54119610014619698439972320536638942006107206337801,
|
---|
78 | .50979557910415916894193980398784391368261849190893,
|
---|
79 | .50241928618815570551167011928012092247859337193963,
|
---|
80 | .50060299823519630134550410676638239611758632599591,
|
---|
81 | .50015063602065098821477101271097658495974913010340,
|
---|
82 | .50003765191554772296778139077905492847503165398345,
|
---|
83 | .50000941253588775676512870469186533538523133757983,
|
---|
84 | .50000235310628608051401267171204408939326297376426,
|
---|
85 | .50000058827484117879868526730916804925780637276181,
|
---|
86 | .50000014706860214875463798283871198206179118093251,
|
---|
87 | .50000003676714377807315864400643020315103490883972,
|
---|
88 | .50000000919178552207366560348853455333939112569380,
|
---|
89 | .50000000229794635411562887767906868558991922348920,
|
---|
90 | .50000000057448658687873302235147272458812263401372
|
---|
91 | };
|
---|
92 | static REAL costab[20]=
|
---|
93 | {
|
---|
94 | .00000000000000000000000000000000000000000000000000,
|
---|
95 | .70710678118654752440084436210484903928483593768847,
|
---|
96 | .92387953251128675612818318939678828682241662586364,
|
---|
97 | .98078528040323044912618223613423903697393373089333,
|
---|
98 | .99518472667219688624483695310947992157547486872985,
|
---|
99 | .99879545620517239271477160475910069444320361470461,
|
---|
100 | .99969881869620422011576564966617219685006108125772,
|
---|
101 | .99992470183914454092164649119638322435060646880221,
|
---|
102 | .99998117528260114265699043772856771617391725094433,
|
---|
103 | .99999529380957617151158012570011989955298763362218,
|
---|
104 | .99999882345170190992902571017152601904826792288976,
|
---|
105 | .99999970586288221916022821773876567711626389934930,
|
---|
106 | .99999992646571785114473148070738785694820115568892,
|
---|
107 | .99999998161642929380834691540290971450507605124278,
|
---|
108 | .99999999540410731289097193313960614895889430318945,
|
---|
109 | .99999999885102682756267330779455410840053741619428
|
---|
110 | };
|
---|
111 | static REAL sintab[20]=
|
---|
112 | {
|
---|
113 | 1.0000000000000000000000000000000000000000000000000,
|
---|
114 | .70710678118654752440084436210484903928483593768846,
|
---|
115 | .38268343236508977172845998403039886676134456248561,
|
---|
116 | .19509032201612826784828486847702224092769161775195,
|
---|
117 | .09801714032956060199419556388864184586113667316749,
|
---|
118 | .04906767432741801425495497694268265831474536302574,
|
---|
119 | .02454122852291228803173452945928292506546611923944,
|
---|
120 | .01227153828571992607940826195100321214037231959176,
|
---|
121 | .00613588464915447535964023459037258091705788631738,
|
---|
122 | .00306795676296597627014536549091984251894461021344,
|
---|
123 | .00153398018628476561230369715026407907995486457522,
|
---|
124 | .00076699031874270452693856835794857664314091945205,
|
---|
125 | .00038349518757139558907246168118138126339502603495,
|
---|
126 | .00019174759731070330743990956198900093346887403385,
|
---|
127 | .00009587379909597734587051721097647635118706561284,
|
---|
128 | .00004793689960306688454900399049465887274686668768
|
---|
129 | };
|
---|
130 | static REAL coswrk[20]=
|
---|
131 | {
|
---|
132 | .00000000000000000000000000000000000000000000000000,
|
---|
133 | .70710678118654752440084436210484903928483593768847,
|
---|
134 | .92387953251128675612818318939678828682241662586364,
|
---|
135 | .98078528040323044912618223613423903697393373089333,
|
---|
136 | .99518472667219688624483695310947992157547486872985,
|
---|
137 | .99879545620517239271477160475910069444320361470461,
|
---|
138 | .99969881869620422011576564966617219685006108125772,
|
---|
139 | .99992470183914454092164649119638322435060646880221,
|
---|
140 | .99998117528260114265699043772856771617391725094433,
|
---|
141 | .99999529380957617151158012570011989955298763362218,
|
---|
142 | .99999882345170190992902571017152601904826792288976,
|
---|
143 | .99999970586288221916022821773876567711626389934930,
|
---|
144 | .99999992646571785114473148070738785694820115568892,
|
---|
145 | .99999998161642929380834691540290971450507605124278,
|
---|
146 | .99999999540410731289097193313960614895889430318945,
|
---|
147 | .99999999885102682756267330779455410840053741619428
|
---|
148 | };
|
---|
149 | static REAL sinwrk[20]=
|
---|
150 | {
|
---|
151 | 1.0000000000000000000000000000000000000000000000000,
|
---|
152 | .70710678118654752440084436210484903928483593768846,
|
---|
153 | .38268343236508977172845998403039886676134456248561,
|
---|
154 | .19509032201612826784828486847702224092769161775195,
|
---|
155 | .09801714032956060199419556388864184586113667316749,
|
---|
156 | .04906767432741801425495497694268265831474536302574,
|
---|
157 | .02454122852291228803173452945928292506546611923944,
|
---|
158 | .01227153828571992607940826195100321214037231959176,
|
---|
159 | .00613588464915447535964023459037258091705788631738,
|
---|
160 | .00306795676296597627014536549091984251894461021344,
|
---|
161 | .00153398018628476561230369715026407907995486457522,
|
---|
162 | .00076699031874270452693856835794857664314091945205,
|
---|
163 | .00038349518757139558907246168118138126339502603495,
|
---|
164 | .00019174759731070330743990956198900093346887403385,
|
---|
165 | .00009587379909597734587051721097647635118706561284,
|
---|
166 | .00004793689960306688454900399049465887274686668768
|
---|
167 | };
|
---|
168 |
|
---|
169 | #endif
|
---|