[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Re: FFT(INVFFT) is not returning original data!
From: |
Sumit Adhikari |
Subject: |
Re: [Help-gsl] Re: FFT(INVFFT) is not returning original data! |
Date: |
Tue, 12 Jan 2010 07:44:59 +0530 |
No, the output is kind of multiplication of two sine waves. Scaling factor
will be there.
Regards,
On Tue, Jan 12, 2010 at 2:17 AM, James Bergstra
<address@hidden>wrote:
> I didn't run your code, but is the difference simply a matter of
> scaling? There is some discussion of this in the documentation.
>
> On Mon, Jan 11, 2010 at 4:54 AM, Sumit Adhikari
> <address@hidden> wrote:
> > A small correction ... "not returning"
> > Sorry for the inconvenience.
> >
> >
> > On Mon, Jan 11, 2010 at 3:22 PM, Sumit Adhikari <
> address@hidden>wrote:
> >
> >> Hello All,
> >> Following function is returning me the original data. Can anybody
> please
> >> tell me what is the problem I am doing with it ?
> >>
> >>
> >> # ifndef SC_FFT_H
> >> # define SC_FFT_H
> >>
> >> # include <cmath>
> >>
> >> # include "systemc.h"
> >>
> >> # include "m_signal_inout_if.h"
> >> # include "m_signal_in_if.h"
> >>
> >>
> >> # include <gsl/gsl_errno.h>
> >> # include <gsl/gsl_fft_complex.h>
> >>
> >> # include "hann.h"
> >>
> >>
> >> # define REAL(z,i) ((z) [2*(i)])
> >> # define IMAG(z,i) ((z) [2*(i) + 1])
> >>
> >> template < typename T > class sc_fft : public sc_module {
> >> public :
> >> sc_port < m_signal_in_if < T > > inp ;
> >> sc_port < m_signal_inout_if < T > > out ;
> >> sc_port < m_signal_inout_if < bool > > tx ;
> >> sc_port < m_signal_inout_if < T > > freq;
> >>
> >>
> >> typedef sc_fft SC_CURRENT_USER_MODULE ;
> >>
> >> sc_fft(sc_module_name name,const unsigned Nfft,T Offset):
> >> inp("inp"),
> >> out("out"),
> >> tx("tx"),
> >> freq("freq"),
> >> sc_module(name),
> >> _Nfft(Nfft) ,
> >> _Offset(Offset) {
> >>
> >> Npoints = _Nfft ;
> >>
> >> i = 0 ;
> >>
> >> fft_inp_buff = (double*) malloc (_Nfft * sizeof(double));
> >> fft_inp_buff = new double [_Nfft] ;
> >>
> >> fft_trn_buff = (double*) malloc (2*_Nfft * sizeof(double));
> >> fft_trn_buff = new double [2*_Nfft] ;
> >>
> >> fft_out_buff = (double*) malloc (_Nfft * sizeof(double));
> >> fft_out_buff = new double [_Nfft] ;
> >>
> >>
> >> SC_METHOD(read);
> >> sensitive << inp ;
> >> }
> >>
> >>
> >> private :
> >> const unsigned _Nfft ;
> >> T _Offset ;
> >> unsigned Npoints ;
> >> unsigned i ;
> >> double* fft_inp_buff ;
> >> double* fft_trn_buff ;
> >> double* fft_out_buff ;
> >>
> >>
> >> void inline read(){
> >> if (i == (Npoints - 1)) {
> >> i = 0 ;
> >>
> >> for(int j = 0 ; j < Npoints ; j++) {
> >> REAL(fft_trn_buff,j) = fft_inp_buff[j];
> >> IMAG(fft_trn_buff,j) = 0.0 ;
> >> }
> >>
> >> int fstatus =
> >> gsl_fft_complex_radix2_forward(fft_trn_buff,1,Npoints);
> >> int rstatus =
> >> gsl_fft_complex_radix2_inverse(fft_trn_buff,1,Npoints);
> >> for(int j = 0 ; j < Npoints ; j++) fft_out_buff[j] =
> >> sqrt(REAL(fft_trn_buff,j)*REAL(fft_trn_buff,j) +
> >> IMAG(fft_trn_buff,j)*IMAG(fft_trn_buff,j)) ;
> >>
> >>
> >> fft_inp_buff[i] = (double) (inp->read() - _Offset);
> >> out->write((T) fft_out_buff[i]);
> >> tx->write(true);
> >>
> >> }
> >> else {
> >> i ++ ;
> >>
> >> fft_inp_buff[i] = (double) (inp->read() - _Offset) ;
> >> out->write((T) fft_out_buff[i]);
> >> tx->write(false);
> >> }
> >>
> >> freq->write((T) i);
> >> }
> >>
> >>
> >> };
> >>
> >>
> >> # endif
> >>
> >> Regards,
> >>
> >> Sumit
> >>
> >
> >
> >
> > --
> >
> > --------------------------------------------
> > Sumit Adhikari
> > System Design Engineer
> > austriamicrosystems AG
> > Business Unit : Automotive
> > Mob : 00-91-9885271710/00-91-9000161710
> > _______________________________________________
> > Help-gsl mailing list
> > address@hidden
> > http://lists.gnu.org/mailman/listinfo/help-gsl
> >
>
>
>
> --
> http://www-etud.iro.umontreal.ca/~bergstrj<http://www-etud.iro.umontreal.ca/%7Ebergstrj>
>
--
--------------------------------------------
Sumit Adhikari
System Design Engineer
austriamicrosystems AG
Business Unit : Automotive
Mob : 00-91-9885271710/00-91-9000161710