P
paul
Hi everyone,
I'm debugging an FFT routine and it has thrown up a perplexing error
which I cannot trace. Cannot anyone help? I've included the relevant
code below with comments:
rlft3(data_in1, speq_out1,1,512,256,1); // Perform FFT on 1st set of
input data
rlft3(data_in2, speq_out2,1,512,256,1); // Now 2nd set
// NB: data_in1/2, speq_out1/2 are indexed from 1
// data_in* are 3D arrays, speq_out* are 2D arrays
// data_in1[1][1][1] has "good data"
// Now do phase correlation
float *sp1, *sp2, r, im;
sp1 = &data_in1[1][1][1];
sp2 = &data_in2[1][1][1];
// data_in1[1][1][1] has "good data"
// Loop through elements multiplying and normalizing
for (int j=1;j<=(1*512*256)/2; j++)
{
r = sp1[0]*sp2[0] + sp1[1]*sp2[1];
im = sp1[1]*sp2[0] - sp1[0]*sp2[1];
sp1[0] = fac*r/sqrt(r*r + im*im);
sp2[1] = fac*im/sqrt(r*r + im*im);
sp1+=2;
sp2+=2;
}
// data_in1[1][1][1] has "good data"
// data_in1[1][1][1] has "good data"
// Do the same for the spectrum elements
sp1 = &speq_out1[1][1];
sp2 = &speq_out2[1][1];
for (j=1;j<=1024; j++)
{
r = sp1[0]*sp2[0] + sp1[1]*sp2[1];
im = sp1[1]*sp2[0] - sp1[0]*sp2[1];
sp1[0] = fac*r/sqrt(r*r + im*im);
sp2[1] = fac*im/sqrt(r*r + im*im);
sp1+=2;
sp2+=2;
}
int ab=1; // Does nothing - just put here for breakpoint purposes
// data_in1[1][1][1] is junk - "Expression cannot be evaluated" .
rlft3(data_in1, speq_out1, 1, 512, 256 , -1); // Do inverse FFT
Somewhere, the array data_in1 is being replaced by junk, although the
pointer value/memory address itself does not change. Whats happening?
TIA
Paul
I'm debugging an FFT routine and it has thrown up a perplexing error
which I cannot trace. Cannot anyone help? I've included the relevant
code below with comments:
rlft3(data_in1, speq_out1,1,512,256,1); // Perform FFT on 1st set of
input data
rlft3(data_in2, speq_out2,1,512,256,1); // Now 2nd set
// NB: data_in1/2, speq_out1/2 are indexed from 1
// data_in* are 3D arrays, speq_out* are 2D arrays
// data_in1[1][1][1] has "good data"
// Now do phase correlation
float *sp1, *sp2, r, im;
sp1 = &data_in1[1][1][1];
sp2 = &data_in2[1][1][1];
// data_in1[1][1][1] has "good data"
// Loop through elements multiplying and normalizing
for (int j=1;j<=(1*512*256)/2; j++)
{
r = sp1[0]*sp2[0] + sp1[1]*sp2[1];
im = sp1[1]*sp2[0] - sp1[0]*sp2[1];
sp1[0] = fac*r/sqrt(r*r + im*im);
sp2[1] = fac*im/sqrt(r*r + im*im);
sp1+=2;
sp2+=2;
}
// data_in1[1][1][1] has "good data"
// data_in1[1][1][1] has "good data"
// Do the same for the spectrum elements
sp1 = &speq_out1[1][1];
sp2 = &speq_out2[1][1];
for (j=1;j<=1024; j++)
{
r = sp1[0]*sp2[0] + sp1[1]*sp2[1];
im = sp1[1]*sp2[0] - sp1[0]*sp2[1];
sp1[0] = fac*r/sqrt(r*r + im*im);
sp2[1] = fac*im/sqrt(r*r + im*im);
sp1+=2;
sp2+=2;
}
int ab=1; // Does nothing - just put here for breakpoint purposes
// data_in1[1][1][1] is junk - "Expression cannot be evaluated" .
rlft3(data_in1, speq_out1, 1, 512, 256 , -1); // Do inverse FFT
Somewhere, the array data_in1 is being replaced by junk, although the
pointer value/memory address itself does not change. Whats happening?
TIA
Paul