Bhaskar,
You are right! I need to study the best way to scale the output.
Thanks a lot!
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
Reply by Bhaskar Thiagarajan●October 6, 20052005-10-06
"euricovaz" <eurico@orbisat.com.br> wrote in message
news:4pGdnZ5hz7wR8djeRVn-iQ@giganews.com...
> Bhaskar,
>
> Really i am not taking care about scaling, this is true. But i think this
> values are wrong because if i run the transforms in the same array, using
> the software IDL, i get the following answers for out vector:
Well, if you look at your numbers carefully, the 'IDL' results for the
inverse fft are *exactly* a scaling factor of 4 from the forwards fft
results. I presume IDL does it's own scaling (see documentation). I'm fairly
sure fftw doesn't (see documentation). That should explain the results.
You can't expect every software package that does the same thing to have the
exact same interface and work in the exact same manner. I'd say both are
working as expected - I see nothing wrong.
Cheers
Bhaskar
>
> -23 123 -122 124 //in vector
> 25.5 24.75 -98 24.75 //out vector (Using IDL, direct fft (-1) )
>
> -23 123 -122 124 // vector in
> 102 99 -392 99 // vector out (Using IDL, inverse fft (1) )
>
>
> Different from fftw, wich gives the same result for both transforms (-1)
> and (1):
>
> -23 123 -122 124 //vector in
> 102 99 -392 99 // vector out (Using FFTW3, direct and inverse ffts)
>
>
>
> This message was sent using the Comp.DSP web interface on
> www.DSPRelated.com
Reply by Jerry Avins●October 6, 20052005-10-06
euricovaz wrote:
> Bhaskar,
>
> Really i am not taking care about scaling, this is true. But i think this
> values are wrong because if i run the transforms in the same array, using
> the software IDL, i get the following answers for out vector:
>
> -23 123 -122 124 //in vector
> 25.5 24.75 -98 24.75 //out vector (Using IDL, direct fft (-1) )
>
> -23 123 -122 124 // vector in
> 102 99 -392 99 // vector out (Using IDL, inverse fft (1) )
>
>
> Different from fftw, wich gives the same result for both transforms (-1)
> and (1):
>
> -23 123 -122 124 //vector in
> 102 99 -392 99 // vector out (Using FFTW3, direct and inverse ffts)
>
>
>
> This message was sent using the Comp.DSP web interface on
> www.DSPRelated.com
The order of elements in the output array and the scaling both depend on
the author of the routine. There is no standard: make sure you know the
way your particular routines are organized. (Some have bit-reversed order.)
jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
Reply by euricovaz●October 6, 20052005-10-06
Bhaskar,
Really i am not taking care about scaling, this is true. But i think this
values are wrong because if i run the transforms in the same array, using
the software IDL, i get the following answers for out vector:
-23 123 -122 124 //in vector
25.5 24.75 -98 24.75 //out vector (Using IDL, direct fft (-1) )
-23 123 -122 124 // vector in
102 99 -392 99 // vector out (Using IDL, inverse fft (1) )
Different from fftw, wich gives the same result for both transforms (-1)
and (1):
-23 123 -122 124 //vector in
102 99 -392 99 // vector out (Using FFTW3, direct and inverse ffts)
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
Reply by Bhaskar Thiagarajan●October 6, 20052005-10-06
"euricovaz" <eurico@orbisat.com.br> wrote in message
news:C46dneLgc8-HutjeRVn-oA@giganews.com...
> >
> >"euricovaz" <eurico@orbisat.com.br> wrote in message
> >news:_7ednY1ibc3Ts9neRVn-rg@giganews.com...
> >> Hi all,
> >>
> >> I am beginner in the fftw. A have made a single code to test how does
> it
> >> work. But i am having the same response if i use FFTW_FORWARD or
> >> FFTW_BACKWARD transforms.
> >> What could be wrong? Here is the code:
<long code snippet snipped>
> >> Before DFT:
> >> -23 123 -122 124
> >> 0 0 0 0
> >>
> >> After DFT:
> >> -23 123 -122 124
> >> 102 99 -392 99
> >>
> >> Thanks a lot for help!
> >
> >I generally don't read code. It seems very unlikely that the first four
>
> >terms of the fft output would be the same as the first four terms of the
>
> >input to the fft. A good place to start looking. Somehow the input is
> >getting into the output.
> >
> >I get:
> >
> >102 57 99 297 392 297 99 57
> >
> >after rounding down the fft result to the nearest integer in floating
> point.
> >
> >If I compute the inverse transform of the same series and consider that
> fftw
> >does not weight in either direction, I get:
> >
> >96 56 96 296 392 296 96 56
> >
> >Fred
> >
> >
> >
> >
>
> Hi Fred,
>
> My program output is causing confusion. In true, i am printing the input
> e output - before and after transforms:
>
> Before DFT:
> -23 123 -122 124 //vector in
> 0 0 0 0 // vector out
>
> After DFT:
> -23 123 -122 124 //vector in
> 102 99 -392 99 // vector out
>
> But the problem is: result is the same if i run the direct ou inverse
> FFT.
> Do you know what could be wrong?
I'm not very familiar with fftw details but the forward and reverse
transforms are essentially the same except for a scaling factor. IIRC, fftw
lets you take care of the scaling - so you'd get the same results. What were
you expecting? Explain in detail why you think this is wrong and perhaps we
can right the wrong in your understanding.
Cheers
Bhaskar
>
> Sorry about the long thread and thanks a lot for your attention!
>
>
> This message was sent using the Comp.DSP web interface on
> www.DSPRelated.com
Reply by euricovaz●October 6, 20052005-10-06
>
>"euricovaz" <eurico@orbisat.com.br> wrote in message
>news:_7ednY1ibc3Ts9neRVn-rg@giganews.com...
>> Hi all,
>>
>> I am beginner in the fftw. A have made a single code to test how does
it
>> work. But i am having the same response if i use FFTW_FORWARD or
>> FFTW_BACKWARD transforms.
>> What could be wrong? Here is the code:
>>
>>
>> #include<fftw3.h>
>> #include<iostream.h>
>> #include<stdlib.h>
>>
>> int main (void)
>> {
>>
>> int N=4; //linebytes size
>> fftw_complex *in, *out;
>> fftw_plan p;
>> int i;
>> float array[4]={-23,123,-122,124};
>>
>> //memory
>> in = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);
>> out = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);
>>
>> //initializing array
>> for(i=0;i<N;i++)in[i][0]=array[i];
>>
>> //printing vectors
>> cout << "Before DFT:" <<endl;
>> for(i=0;i<N;i++)cout << in[i][0] << " ";
>> cout << endl;
>> for(i=0;i<N;i++)cout << out[i][0] << " ";
>> cout << endl <<endl;
>>
>> //creating the plan
>> p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
>>
>> //executing
>> fftw_execute(p);
>>
>> //printing vectors
>> cout << "After DFT:" <<endl;
>> for(i=0;i<N;i++)cout << in[i][0] << " ";
>> cout << endl;
>> for(i=0;i<N;i++)cout << out[i][0] << " ";
>> cout << endl;
>>
>> //memory free
>> fftw_destroy_plan(p);
>> fftw_free(in);
>> fftw_free(out);
>> }
>>
>> Running, I have the same response if i use FFTW_FORWARD or
FFTW_BACKWARD
>> as plan parameter:
>>
>> Before DFT:
>> -23 123 -122 124
>> 0 0 0 0
>>
>> After DFT:
>> -23 123 -122 124
>> 102 99 -392 99
>>
>> Thanks a lot for help!
>
>I generally don't read code. It seems very unlikely that the first four
>terms of the fft output would be the same as the first four terms of the
>input to the fft. A good place to start looking. Somehow the input is
>getting into the output.
>
>I get:
>
>102 57 99 297 392 297 99 57
>
>after rounding down the fft result to the nearest integer in floating
point.
>
>If I compute the inverse transform of the same series and consider that
fftw
>does not weight in either direction, I get:
>
>96 56 96 296 392 296 96 56
>
>Fred
>
>
>
>
Hi Fred,
My program output is causing confusion. In true, i am printing the input
e output - before and after transforms:
Before DFT:
-23 123 -122 124 //vector in
0 0 0 0 // vector out
After DFT:
-23 123 -122 124 //vector in
102 99 -392 99 // vector out
But the problem is: result is the same if i run the direct ou inverse
FFT.
Do you know what could be wrong?
Sorry about the long thread and thanks a lot for your attention!
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
Reply by Fred Marshall●October 6, 20052005-10-06
"euricovaz" <eurico@orbisat.com.br> wrote in message
news:_7ednY1ibc3Ts9neRVn-rg@giganews.com...
> Hi all,
>
> I am beginner in the fftw. A have made a single code to test how does it
> work. But i am having the same response if i use FFTW_FORWARD or
> FFTW_BACKWARD transforms.
> What could be wrong? Here is the code:
>
>
> #include<fftw3.h>
> #include<iostream.h>
> #include<stdlib.h>
>
> int main (void)
> {
>
> int N=4; //linebytes size
> fftw_complex *in, *out;
> fftw_plan p;
> int i;
> float array[4]={-23,123,-122,124};
>
> //memory
> in = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);
> out = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);
>
> //initializing array
> for(i=0;i<N;i++)in[i][0]=array[i];
>
> //printing vectors
> cout << "Before DFT:" <<endl;
> for(i=0;i<N;i++)cout << in[i][0] << " ";
> cout << endl;
> for(i=0;i<N;i++)cout << out[i][0] << " ";
> cout << endl <<endl;
>
> //creating the plan
> p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
>
> //executing
> fftw_execute(p);
>
> //printing vectors
> cout << "After DFT:" <<endl;
> for(i=0;i<N;i++)cout << in[i][0] << " ";
> cout << endl;
> for(i=0;i<N;i++)cout << out[i][0] << " ";
> cout << endl;
>
> //memory free
> fftw_destroy_plan(p);
> fftw_free(in);
> fftw_free(out);
> }
>
> Running, I have the same response if i use FFTW_FORWARD or FFTW_BACKWARD
> as plan parameter:
>
> Before DFT:
> -23 123 -122 124
> 0 0 0 0
>
> After DFT:
> -23 123 -122 124
> 102 99 -392 99
>
> Thanks a lot for help!
I generally don't read code. It seems very unlikely that the first four
terms of the fft output would be the same as the first four terms of the
input to the fft. A good place to start looking. Somehow the input is
getting into the output.
I get:
102 57 99 297 392 297 99 57
after rounding down the fft result to the nearest integer in floating point.
If I compute the inverse transform of the same series and consider that fftw
does not weight in either direction, I get:
96 56 96 296 392 296 96 56
Fred
Reply by euricovaz●October 5, 20052005-10-05
Hi all,
I am beginner in the fftw. A have made a single code to test how does it
work. But i am having the same response if i use FFTW_FORWARD or
FFTW_BACKWARD transforms.
What could be wrong? Here is the code:
#include<fftw3.h>
#include<iostream.h>
#include<stdlib.h>
int main (void)
{
int N=4; //linebytes size
fftw_complex *in, *out;
fftw_plan p;
int i;
float array[4]={-23,123,-122,124};
//memory
in = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);
out = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);
//initializing array
for(i=0;i<N;i++)in[i][0]=array[i];
//printing vectors
cout << "Before DFT:" <<endl;
for(i=0;i<N;i++)cout << in[i][0] << " ";
cout << endl;
for(i=0;i<N;i++)cout << out[i][0] << " ";
cout << endl <<endl;
//creating the plan
p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
//executing
fftw_execute(p);
//printing vectors
cout << "After DFT:" <<endl;
for(i=0;i<N;i++)cout << in[i][0] << " ";
cout << endl;
for(i=0;i<N;i++)cout << out[i][0] << " ";
cout << endl;
//memory free
fftw_destroy_plan(p);
fftw_free(in);
fftw_free(out);
}
Running, I have the same response if i use FFTW_FORWARD or FFTW_BACKWARD
as plan parameter:
Before DFT:
-23 123 -122 124
0 0 0 0
After DFT:
-23 123 -122 124
102 99 -392 99
Thanks a lot for help!
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com