47 #define PI8 0.392699081698724 48 #define RT2 1.4142135623731 49 #define IRT2 0.707106781186548 51 static void FR2TR(
int,
float*,
float*);
52 static void FR4TR(
int,
int,
float*,
float*,
float*,
float*);
53 static void FORD1(
int,
float*);
54 static void FORD2(
unsigned int,
float*);
83 float tmp_real,tmp_imag;
89 N = (
int)pow(
float(2.0),(float)M);
99 int le = (
int)pow(
float(2.0),(float)(M+1-l));
106 w_imag=f * sin(
PI/le1);
110 for (i=j;i<=N-le1;i+=le)
119 real.
a_no_check(ip-1) = tmp_real*u_real - tmp_imag*u_imag;
120 imag.
a_no_check(ip-1) = tmp_real*u_imag + tmp_imag*u_real;
126 tmp_real = u_real*w_real - u_imag*w_imag;
127 tmp_imag = u_real*w_imag + u_imag*w_real;
142 for (i=1; i<=NM1;i++)
149 real[j-1] = real(i-1);
150 imag[j-1] = imag(i-1);
175 return slowFFTsub(real,imag,-1.0);
185 if (slowFFTsub(real,imag,1.0) != 0)
188 for(
int i=1;i<=N;i++){
189 real[i-1] /= (float)N;
190 imag[i-1] /= (float)N;
203 for(i=0;i<real.
n();i++)
204 real[i] = imag[i] = (real(i)*real(i) + imag(i)*imag(i));
216 for(i=0;i<real.
n();i++)
217 real[i] = imag[i] = sqrt((real(i)*real(i) + imag(i)*imag(i)));
230 for(i=0,j=0, k=1;i<n;i+=2,j++,k+=2)
254 #define signum(i) (i < 0 ? -1 : i == 0 ? 0 : 1) 260 int i, in, nn, n2pow, n4pow;
273 float *b =
new float[n];
280 if (n2pow <= 0)
return 0;
290 FR2TR(in, b, b + in );
295 for(i = 1; i <= n4pow; i++) {
298 FR4TR(in, nn, b, b + in, b + 2 * in, b + 3 * in);
306 for(i = 3; i < n; i += 2) b[i] = -b[i];
318 void FR2TR(
int in,
float *b0,
float *b1)
322 for (k = 0; k < in; k++)
325 b1[k] = b0[k] - b1[k];
331 void FR4TR(
int in,
int nn,
float *b0,
float *b1,
float *b2,
float* b3) {
332 float arg, piovn, th2;
333 float *b4 = b0, *b5 = b1, *b6 = b2, *b7 = b3;
334 float t0, t1, t2, t3, t4, t5, t6, t7;
335 float r1, r5,
pr, pi;
336 float c1, c2, c3, s1, s2, s3;
338 int j, k, jj, kk, jthet, jlast, ji, jl, jr, int4;
339 int L[16], L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15;
340 int j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14;
344 for(k = 2; k < 16; k++) {
345 switch (
signum(L[k-1] - 2)) {
358 L15=L[1]; L14=L[2]; L13=L[3]; L12=L[4]; L11=L[5]; L10=L[6]; L9=L[7];
359 L8=L[8]; L7=L[9]; L6=L[10]; L5=L[11]; L4=L[12]; L3=L[13]; L2=L[14];
367 for(j1=2;j1<=L1;j1+=2)
368 for(j2=j1;j2<=L2;j2+=L1)
369 for(j3=j2;j3<=L3;j3+=L2)
370 for(j4=j3;j4<=L4;j4+=L3)
371 for(j5=j4;j5<=L5;j5+=L4)
372 for(j6=j5;j6<=L6;j6+=L5)
373 for(j7=j6;j7<=L7;j7+=L6)
374 for(j8=j7;j8<=L8;j8+=L7)
375 for(j9=j8;j9<=L9;j9+=L8)
376 for(j10=j9;j10<=L10;j10+=L9)
377 for(j11=j10;j11<=L11;j11+=L10)
378 for(j12=j11;j12<=L12;j12+=L11)
379 for(j13=j12;j13<=L13;j13+=L12)
380 for(j14=j13;j14<=L14;j14+=L13)
381 for(jthet=j14;jthet<=L15;jthet+=L14)
390 b2[k] = b0[k] - b2[k];
391 b3[k] = b1[k] - b3[k];
402 pr =
IRT2 * (b1[kk]-b3[kk]);
403 pi =
IRT2 * (b1[kk]+b3[kk]);
404 b3[kk] = b2[kk] + pi;
405 b1[kk] = pi - b2[kk];
406 b2[kk] = b0[kk] -
pr;
407 b0[kk] = b0[kk] +
pr;
425 for(j=j0;j<=jlast;j++)
429 r1 = b1[jj]*c1 - b5[kk]*s1;
430 r5 = b1[jj]*s1 + b5[kk]*c1;
431 t2 = b2[jj]*c2 - b6[kk]*s2;
432 t6 = b2[jj]*s2 + b6[kk]*c2;
433 t3 = b3[jj]*c3 - b7[kk]*s3;
434 t7 = b3[jj]*s3 + b7[kk]*c3;
463 void FORD1(
int m,
float *b) {
464 int j, k = 4, kl = 2, n = 0x1 << m;
467 for(j = 4; j <= n; j += 2) {
481 void FORD2(
unsigned int m,
float *b) {
483 const int n = 0x1<<m;
513 for (
int j1=2;j1<=
l1;j1+=2) {
514 for (
int j2=j1;j2<=
l2;j2+=
l1) {
515 for (
int j3=j2;j3<=
l3;j3+=
l2) {
516 for (
int j4=j3;j4<=
l4;j4+=
l3) {
517 for (
int j5=j4;j5<=
l5;j5+=
l4) {
518 for (
int j6=j5;j6<=
l6;j6+=
l5) {
519 for (
int j7=j6;j7<=
l7;j7+=
l6) {
520 for (
int j8=j7;j8<=
l8;j8+=
l7) {
521 for (
int j9=j8;j9<=
l9;j9+=
l8) {
522 for (
int j10=j9;j10<=
l10;j10+=
l9) {
523 for (
int j11=j10;j11<=
l11;j11+=
l10) {
524 for (
int j12=j11;j12<=
l12;j12+=
l11) {
525 for (
int j13=j12;j13<=
l13;j13+=
l12) {
526 for (
int j14=j13;j14<=
l14;j14+=
l13) {
527 for (
int ji=j14;ji<=
l15;ji+=
l14) {
556 int num_bits,
power = 0;
558 if ((n < 2) || (n % 2 != 0))
return(0);
559 num_bits =
sizeof(
int) * 8;
561 while(power <= num_bits) {
565 if (n > 1)
return(0);
A vector class for floating point numbers. EST_FVector x should be used instead of float *x wherever ...
INLINE const T & a_no_check(ssize_t n) const
read-only const access operator: without bounds checking
void power(EST_Wave &sig, EST_Track &a, float factor)
int energy_spectrum(EST_FVector &real, EST_FVector &imag)
INLINE ssize_t n() const
number of items in vector.