Ignore:
Timestamp:
Aug 8, 2001, 12:39:10 PM (24 years ago)
Author:
cmv
Message:

routines de normalisation des fft cmv 8/8/01

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/NTools/fftservintf.cc

    r1405 r1630  
    157157
    158158
     159// ----------------- Transformation de normalisation pour les energies -------------------
     160
     161/* --Methode-- */
     162//! Compute the transform to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
     163/*!
     164\return The factor to be applied to the FFT energy such that we get the same energy as for the x.
     165\verbatim
     166  fftx is computed by: FFTForward(x,fftx)
     167  Energy of x    : Ex    = sum{|x(i)|^2}      i=0,x.Size()-1
     168  Energy of fftx : Efftx = sum{|fftx(i)^2|}   i=0,fftx.Size()-1
     169        ( usually x.Size() != fftx.Size() )
     170  -------------------------------------------------------------------
     171  |  TransfEnergyFFT return A and B such that : Ex = A * Efftx + B  |
     172  |                  and Norm such that : Ex = Norm * Efftx         |
     173  -------------------------------------------------------------------
     174  To normalize the fftx vector apply : "fftx *= sqrt(Norm)"
     175\endverbatim
     176*/
     177r_8 FFTServerInterface::TransfEnergyFFT
     178     (TVector< complex<r_8> > const& x, TVector< complex<r_8> > const& fftx, r_8& A, r_8& B)
     179{
     180  B=0.;
     181  if(getNormalize()) A = x.Size(); else A = 1./x.Size();
     182  r_8 norm = A;
     183  return norm;
     184}
     185
     186//! Compute the transform to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
     187r_8 FFTServerInterface::TransfEnergyFFT
     188     (TVector< complex<r_4> > const & x, TVector< complex<r_4> > const & fftx, r_8& A, r_8& B)
     189{
     190  B=0.;
     191  if(getNormalize()) A = x.Size(); else A = 1./x.Size();
     192  r_8 norm = A;
     193  return norm;
     194}
     195
     196//! Compute the transform to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
     197r_8 FFTServerInterface::TransfEnergyFFT
     198     (TVector< r_8 > const & x, TVector< complex<r_8> > const & fftx, r_8& A, r_8& B)
     199{
     200  A= 2.;
     201  B=  - abs(fftx(0)*fftx(0));
     202  if(x.Size()%2 == 0) B -= abs(fftx(fftx.Size()-1)*fftx(fftx.Size()-1));
     203  if(getNormalize()) {A *= x.Size(); B *= x.Size();}
     204     else            {A /= x.Size(); B /= x.Size();}
     205  r_8 norm = 0.;
     206  for(int_4 i=0;i<fftx.Size();i++) norm += abs(fftx(i)*fftx(i));
     207  if(norm>0.) norm = (A*norm+B)/norm;
     208  return norm;
     209}
     210
     211//! Compute the transform to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
     212r_8 FFTServerInterface::TransfEnergyFFT
     213     (TVector< r_4 > const & x, TVector< complex<r_4> > const & fftx, r_8& A, r_8& B)
     214{
     215  A= 2.;
     216  B=  - abs(fftx(0)*fftx(0));
     217  if(x.Size()%2 == 0) B -= abs(fftx(fftx.Size()-1)*fftx(fftx.Size()-1));
     218  if(getNormalize()) {A *= x.Size(); B *= x.Size();}
     219     else            {A /= x.Size(); B /= x.Size();}
     220  r_8 norm = 0.;
     221  for(int_4 i=0;i<fftx.Size();i++) norm += abs(fftx(i)*fftx(i));
     222  if(norm>0.) norm = (A*norm+B)/norm;
     223  return norm;
     224}
     225
    159226
    160227/* --Methode-- */
     
    195262  return(1.e-9);
    196263}
    197 
    198 
    199264
    200265/* --Methode-- */
Note: See TracChangeset for help on using the changeset viewer.