nmpp
fftext.h
1//***************************************************************************/
2//* RC Module Inc., Moscow, Russia */
3//* NeuroMatrix(r) NM6403 Software */
4//* */
5//* Fast Fourie Transform Library */
6//* (C-callable functions) */
7//* */
8//* $Workfile:: FFText.h $*/
9//* Contents: Header file of FFT extended routines */
10//* */
11//* */
12//* Author: S.Mushkaev */
13//* */
14//* Version 1.0 */
15//* Start Date: 03.07.2001 */
16//* Release $Date: 2005/02/10 11:47:59 $*/
17//* */
18//* */
19//***************************************************************************/
20
21// LIBRARY pcfft.lib
22
23
24//#########################################################################################
25// The functions declared below are used for modeling and researching FFT calculations on PC
26// using fixed and floating-point arithmetic on PC.
27#ifndef _FFTEXT_H_INCLUDED_
28#define _FFTEXT_H_INCLUDED_
29
30#define FFT7BIT 1
31#define FFT6BIT 2
32
33#ifndef __NM__
34
35#include "nmtl.h"
36#include "nmtype.h"
37#include "crtdbg2.h"
38
39
40
42{
43public:
44 double Re;
45 double Im;
46} ;
47
49{
50public:
51 char Re;
52 char Im;
53} ;
54
55
56
57//********************************************************************
59// Computing FFT-256 using fixed-point arithmetic
60// This is the C equivalent of the FFT_Fwd256 Assembly Code
61int FFT_Fwd256(
62 vec<cmplx<int> > &X,
63 vec<cmplx<int> > &Y,
64 vec<cmplx<char> > &W1_256,
65 vec<cmplx<char> > &W2_256,
66 int Shr1,
67 int Shr2
68 );
70// Computing FFT-256 using floating-point arithmetic
71int FFT256(
72 vec<cmplx<double> > &X, // Source buffer :long[256]
73 vec<cmplx<double> > &Y // Result FFT :long[256]
74 );
76// Initialization FFT table of char coefficients
77void MakeTable256W1W2(
78 vec<cmplx<char> > &W1_256,
79 vec<cmplx<char> > &W2_256,
80 double Ampl
81 );
82
83//********************************************************************
85// Computing FFT-1024 using fixed-point arithmetic
86// This is the C equivalent of the FFT_Fwd512 Assembly Code
87int FFT_Fwd512(
88 vec<cmplx<int> > &X, // input array
89 vec<cmplx<int> > &Y, // output array
90 vec<cmplx<char> > &W1_512, // table of coefficients
91 vec<cmplx<char> > &W2_512, // table of coefficients
92 int Shr1, // 1-st shiftr normalization
93 int Shr2 // 2-nd shiftr normalization
94 );
96// Computing FFT-512 using floating-point arithmetic
97int FFT512(
98 vec<cmplx<double> > &X, // Source buffer :long[512]
99 vec<cmplx<double> > &Y // Result FFT :long[512]
100 );
102// Initialization FFT table of char coefficients
103void MakeTable512W1W2(
104 vec<cmplx<char> > &W1_512,
105 vec<cmplx<char> > &W2_512,
106 double Ampl
107 );
108//********************************************************************
110// Computing FFT-1024 using fixed-point arithmetic
111// This is the C equivalent of the FFT_Fwd1024 Assembly Code
112int FFT_Fwd1024(
113 vec<cmplx<int> > &X, // input array
114 vec<cmplx<int> > &Y, // output array
115 vec<cmplx<char> > &W1_1024,// table of coefficients
116 vec<cmplx<char> > &W2_1024,// table of coefficients
117 int Shr1, // 1-st shiftr normalization
118 int Shr2 // 2-nd shiftr normalization
119 );
121// Computing FFT-1024 using floating-point arithmetic
122int FFT1024(
123 vec<cmplx<double> > &X, // Source buffer :long[1024]
124 vec<cmplx<double> > &Y // Result FFT :long[1024]
125 );
127// Initialization table of char coefficients
128void MakeTable1024W1W2(
129 vec<cmplx<char> > &W1_1024,
130 vec<cmplx<char> > &W2_1024,
131 double Ampl
132 );
133//********************************************************************
135// Computing FFT-2048 using fixed-point arithmetic
136// This is the C equivalent of the FFT_Fwd2048 Assembly Code
137int FFT_Fwd2048(
138 vec<cmplx<int> > &X, // input array
139 vec<cmplx<int> > &Y, // output array
140 vec<cmplx<char> > &W1_2048,// table of coefficients
141 vec<cmplx<char> > &W2_2048,// table of coefficients
142 int Shr1, // 1-st shiftr normalization
143 int Shr2 // 2-nd shiftr normalization
144 );
146// Computing FFT-2048 using floating-point arithmetic
147int FFT2048(
148 vec<cmplx<double> > &X, // Source buffer :long[1024]
149 vec<cmplx<double> > &Y // Result FFT :long[1024]
150 );
152// Initialization table of char coefficients
153void MakeTable2048W1W2(
154 vec<cmplx<char> > &W1_2048,
155 vec<cmplx<char> > &W2_2048,
156 double Ampl
157 );
158//********************************************************************
160// Computing FFT-4096 using floating-point arithmetic
161void FFT_Fwd4096_float1(
162 Cplx_float *X, // Source buffer :long[4096]
163 Cplx_float *Y // Result FFT :long[4096]
164 );
165//********************************************************************
167// Computing IFFT-256 using fixed-point arithmetic
168// This is the C equivalent of the FFT_Fwd256 Assembly Code
169int FFT_Inv256(
170 vec<cmplx<int> > &X,
171 vec<cmplx<int> > &Y,
172 vec<cmplx<char> > &IW1_256,
173 vec<cmplx<char> > &IW2_256,
174 int Shr1,
175 int Shr2
176 );
178// Computing IFFT-256 using floating-point arithmetic
179int IFFT256(
180 vec<cmplx<double> > &X, // Source buffer :long[256]
181 vec<cmplx<double> > &Y // Result FFT :long[256]
182 );
184// Initialization table of char coefficients
185void IMakeTable256W1W2(
186 vec<cmplx<char> > &IW1_256,
187 vec<cmplx<char> > &IW2_256,
188 double Ampl
189 );
190//********************************************************************
192// Computing IFFT-512 using fixed-point arithmetic
193// This is the C equivalent of the FFT_Inv512 Assembly Code
194int FFT_Inv512(
195 vec<cmplx<int> > &X, // input array
196 vec<cmplx<int> > &Y, // output array
197 vec<cmplx<char> > &IW1_512, // table of coefficients
198 vec<cmplx<char> > &IW2_512, // table of coefficients
199 int Shr1, // 1-st shiftr normalization
200 int Shr2 // 2-nd shiftr normalization
201 );
203// Computing FFT-512 using floating-point arithmetic
204int IFFT512(
205 vec<cmplx<double> > &X, // Source buffer :long[512]
206 vec<cmplx<double> > &Y // Result IFFT :long[512]
207 );
209// Initialization table of char coefficients
210void IMakeTable512W1W2(
211 vec<cmplx<char> > &IW1_512,
212 vec<cmplx<char> > &IW2_512,
213 double Ampl
214 );
215//********************************************************************
217// Computing FFT-1024 using fixed-point arithmetic
218// This is the C equivalent of the FFT_Fwd1024 Assembly Code
219int FFT_Inv1024(
220 vec<cmplx<int> > &X, // input array
221 vec<cmplx<int> > &Y, // output array
222 vec<cmplx<char> > &IW1_1024,// table of coefficients
223 vec<cmplx<char> > &IW2_1024, // table of coefficients
224 int Shr1, // 1-st shiftr normalization
225 int Shr2 // 2-nd shiftr normalization
226 );
228// Computing IFFT-1024 using floating-point arithmetic
229int IFFT1024(
230 vec<cmplx<double> > &X, // Source buffer :long[1024]
231 vec<cmplx<double> > &Y // Result IFFT :long[1024]
232 );
234// Initialization table of char coefficients
235void IMakeTable1024W1W2(
236 vec<cmplx<char> > &IW1_1024,
237 vec<cmplx<char> > &IW2_1024,
238 double Ampl);
239//********************************************************************
240
242// Computing IFFT-2048 using fixed-point arithmetic
243// This is the C equivalent of the FFT_Inv2048 Assembly Code
244int FFT_Inv2048(
245 vec<cmplx<int> > &X, // input array
246 vec<cmplx<int> > &Y, // output array
247 vec<cmplx<char> > &IW1_2048, // table of coefficients
248 vec<cmplx<char> > &IW2_2048, // table of coefficients
249 int Shr1, // 1-st shiftr normalization
250 int Shr2 // 2-nd shiftr normalization
251 );
253// Computing IFFT-2048 using floating-point arithmetic
254int IFFT2048(
255 vec<cmplx<double> > &X, // Source buffer :long[1024]
256 vec<cmplx<double> > &Y // Result IFFT :long[1024]
257 );
259// Initialization table of char coefficients
260void IMakeTable2048W1W2(
261 vec<cmplx<char> > &IW1_2048,
262 vec<cmplx<char> > &IW2_2048,
263 double Ampl
264 );
265//********************************************************************
267// Computing IFFT-4096 using floating-point arithmetic
268void FFT_Inv4096_float1(
269 Cplx_float *X, // Source buffer :long[4096]
270 Cplx_float *Y // Result IFFT :long[4096]
271 );
272//********************************************************************
273// Radix-2 FFT-256 Functions
274
275// Computing IFFT-256 using floating-point arithmetic by radix-2 method
276int IFFT256_radix2(
277 vec<cmplx<double> > &X, // Source buffer
278 vec<cmplx<double> > &Y // Result IFFT
279 );
280// Computing FFT-256 using floating-point arithmetic by radix-2 method
281int FFT256_radix2(
282 vec<cmplx<double> > &X, // Source buffer :long[256]
283 vec<cmplx<double> > &Y // Result FFT :long[256]
284 );
285// Computing FFT-256 using fixed-point arithmetic by radix-2 method
286int FFT256_int_radix2(
287 vec<cmplx<int> > &X,
288 vec<cmplx<int> > &Y);
289// Computing FFT-256 using fixed-point arithmetic by radix-2 method
290int IFFT256_int_radix2(
291 vec<cmplx<int> > &X,
292 vec<cmplx<int> > &Y
293 );
294
295
296__INLINE__ void CmplxPack8to64(
297 vec<cmplx<char> > &W,
298 vec<nmint64s > &WRePacked,
299 vec<nmint64s > &WImPacked)
300{
301 ASSERTE(W.size==WRePacked.size*8);
302 ASSERTE(W.size==WImPacked.size*8);
303
304 __int64 PackageIm=0,PackageRe=0;
305 __int64 ByteMask=0xFF;
306 for(int i=0,k=0;i<WRePacked.size;i++,k+=8)
307 {
308 for(int j=7;j>=0;j--)
309 {
310 PackageRe<<=8;
311 PackageRe=PackageRe|(W[k+j].re& ByteMask);
312
313 PackageIm<<=8;
314 PackageIm=PackageIm|(W[k+j].im& ByteMask);
315 }
316 WRePacked[i]=PackageRe;
317 WImPacked[i]=PackageIm;
318 }
319}
320
321//__INLINE__ void OutTable(vec<nmint64s > &Table,nm8s*TableName,nm8s* Section)
322__INLINE__ void OutTable(vec<nmint64s > &Table,char*TableName,char* Section)
323//__INLINE__ void OutTable(nmvec64s &Table,char*TableName,char* Section)
324{
325/*
326 cout << "data" << '"'<< Section << '"' <<endl;
327
328 cout << "global " << TableName << ":long["<< dec << Table.size<<"]=(" << endl;
329 cout << Table << ')'<<';'<<endl;
330
331 cout << "end "<< '"'<< Section <<'"' <<';' <<endl;
332*/
333}
334
335
336
337#endif // NM6403
338#endif //_NMFFTEXT_H_INCLUDED_
Definition: fftext.h:42
Definition: fftext.h:49
Definition: tvector.h:80
void FFT_Fwd1024(nm32sc *GSrcBuffer, nm32sc *LDstBuffer, void *LBuffer, void *GBuffer, int ShiftR=-1)
Прямое быстрое преобразование Фурье-1024.
void FFT_Fwd2048(nm32sc *GSrcBuffer, nm32sc *GDstBuffer, void *LBuffer, int ShiftR=-1)
Прямое быстрое преобразование Фурье-2048.
void FFT_Fwd256(nm32sc *GSrcBuffer, nm32sc *LDstBuffer, void *LBuffer, void *GBuffer, int ShiftR=-1)
Прямое быстрое преобразование Фурье-256.
void FFT_Fwd512(nm32sc *GSrcBuffer, nm32sc *GDstBuffer, void *LBuffer, void *GBuffer, int ShiftR=-1)
Прямое быстрое преобразование Фурье-512.
void FFT_Inv1024(nm32sc *GSrcBuffer, nm32sc *GDstBuffer, void *LBuffer, void *GBuffer, int ShiftR1=10, int ShiftR2=-1)
Обратное быстрое преобразование Фурье. ОБПФ-1024.
void FFT_Inv2048(nm32sc *GSrcBuffer, nm32sc *LDstBuffer, void *LBuffer, void *GBuffer, int ShiftR1=11, int ShiftR2=-1)
Обратное быстрое преобразование Фурье. ОБПФ-2048.
void FFT_Inv256(nm32sc *GSrcBuffer, nm32sc *GDstBuffer, void *LBuffer, void *GBuffer, int ShiftR1=8, int ShiftR2=-1)
Обратное быстрое преобразование Фурье. ОБПФ-256.
void FFT_Inv512(nm32sc *GSrcBuffer, nm32sc *LDstBuffer, void *LBuffer, void *GBuffer, int ShiftR1=9, int ShiftR2=-1)
Обратное быстрое преобразование Фурье. ОБПФ-512.