F
fl
Hi,
I have c function {bitrev_cplx} with having function parameters float
array. In the function bitrev_cplx internal, some array members will
be swap value. I find that when array index i1=1, xi1 gets the right
value, but when j1=16, xj1 gets the wrong value (very large 1.32xx e+8
for example). I suspect the pointer, function parameter usage are
wrong, but I cannot find what is wrong. Could you help check my code?
Thanks a lot.
.....................
void bitrev_cplx (float *, int *, int );
int main()
{
float x[32*2];
float fw[16*2], fwc[16], fws[16];
for (i=0; i<32/2; i++){
fwc = cos(2*PI*i/32);
fws = sin(2*PI*i/32);
}
bitrev_cplx (fwc, temp, nx);
}
void bitrev_cplx (float *x, int *index, int nx)
{
int i;
int i0, i1, i2, i3;
int j0, j1, j2, j3;
float xi0, xi1, xi3;
float xj0, xj1, xj3;
if (t){
x[i0] = xj0;
x[j0] = xi0;
}
i1 = i0 + 1;
j1 = j0 + halfn;
xi1 = x[i1];
xj1 = x[j1];
}
I have c function {bitrev_cplx} with having function parameters float
array. In the function bitrev_cplx internal, some array members will
be swap value. I find that when array index i1=1, xi1 gets the right
value, but when j1=16, xj1 gets the wrong value (very large 1.32xx e+8
for example). I suspect the pointer, function parameter usage are
wrong, but I cannot find what is wrong. Could you help check my code?
Thanks a lot.
.....................
void bitrev_cplx (float *, int *, int );
int main()
{
float x[32*2];
float fw[16*2], fwc[16], fws[16];
for (i=0; i<32/2; i++){
fwc = cos(2*PI*i/32);
fws = sin(2*PI*i/32);
}
bitrev_cplx (fwc, temp, nx);
}
void bitrev_cplx (float *x, int *index, int nx)
{
int i;
int i0, i1, i2, i3;
int j0, j1, j2, j3;
float xi0, xi1, xi3;
float xj0, xj1, xj3;
if (t){
x[i0] = xj0;
x[j0] = xi0;
}
i1 = i0 + 1;
j1 = j0 + halfn;
xi1 = x[i1];
xj1 = x[j1];
}