Index: /trunk/SophyaLib/NTools/fftservintf.cc
===================================================================
--- /trunk/SophyaLib/NTools/fftservintf.cc	(revision 1629)
+++ /trunk/SophyaLib/NTools/fftservintf.cc	(revision 1630)
@@ -157,4 +157,71 @@
 
 
+// ----------------- Transformation de normalisation pour les energies -------------------
+
+/* --Methode-- */
+//! Compute the transform to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
+/*!
+\return The factor to be applied to the FFT energy such that we get the same energy as for the x.
+\verbatim
+  fftx is computed by: FFTForward(x,fftx)
+  Energy of x    : Ex    = sum{|x(i)|^2}      i=0,x.Size()-1
+  Energy of fftx : Efftx = sum{|fftx(i)^2|}   i=0,fftx.Size()-1
+        ( usually x.Size() != fftx.Size() )
+  -------------------------------------------------------------------
+  |  TransfEnergyFFT return A and B such that : Ex = A * Efftx + B  |
+  |                  and Norm such that : Ex = Norm * Efftx         |
+  -------------------------------------------------------------------
+  To normalize the fftx vector apply : "fftx *= sqrt(Norm)"
+\endverbatim
+*/
+r_8 FFTServerInterface::TransfEnergyFFT
+     (TVector< complex<r_8> > const& x, TVector< complex<r_8> > const& fftx, r_8& A, r_8& B)
+{
+  B=0.;
+  if(getNormalize()) A = x.Size(); else A = 1./x.Size();
+  r_8 norm = A;
+  return norm;
+}
+
+//! Compute the transform to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
+r_8 FFTServerInterface::TransfEnergyFFT
+     (TVector< complex<r_4> > const & x, TVector< complex<r_4> > const & fftx, r_8& A, r_8& B)
+{
+  B=0.;
+  if(getNormalize()) A = x.Size(); else A = 1./x.Size();
+  r_8 norm = A;
+  return norm;
+}
+
+//! Compute the transform to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
+r_8 FFTServerInterface::TransfEnergyFFT
+     (TVector< r_8 > const & x, TVector< complex<r_8> > const & fftx, r_8& A, r_8& B)
+{
+  A= 2.;
+  B=  - abs(fftx(0)*fftx(0));
+  if(x.Size()%2 == 0) B -= abs(fftx(fftx.Size()-1)*fftx(fftx.Size()-1));
+  if(getNormalize()) {A *= x.Size(); B *= x.Size();}
+     else            {A /= x.Size(); B /= x.Size();}
+  r_8 norm = 0.;
+  for(int_4 i=0;i<fftx.Size();i++) norm += abs(fftx(i)*fftx(i));
+  if(norm>0.) norm = (A*norm+B)/norm;
+  return norm;
+}
+
+//! Compute the transform to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
+r_8 FFTServerInterface::TransfEnergyFFT
+     (TVector< r_4 > const & x, TVector< complex<r_4> > const & fftx, r_8& A, r_8& B)
+{
+  A= 2.;
+  B=  - abs(fftx(0)*fftx(0));
+  if(x.Size()%2 == 0) B -= abs(fftx(fftx.Size()-1)*fftx(fftx.Size()-1));
+  if(getNormalize()) {A *= x.Size(); B *= x.Size();}
+     else            {A /= x.Size(); B /= x.Size();}
+  r_8 norm = 0.;
+  for(int_4 i=0;i<fftx.Size();i++) norm += abs(fftx(i)*fftx(i));
+  if(norm>0.) norm = (A*norm+B)/norm;
+  return norm;
+}
+
 
 /* --Methode-- */
@@ -195,6 +262,4 @@
   return(1.e-9);
 }
-
-
 
 /* --Methode-- */
Index: /trunk/SophyaLib/NTools/fftservintf.h
===================================================================
--- /trunk/SophyaLib/NTools/fftservintf.h	(revision 1629)
+++ /trunk/SophyaLib/NTools/fftservintf.h	(revision 1630)
@@ -38,14 +38,36 @@
   virtual void FFTForward(TArray< complex<r_8> > const & in, TArray< complex<r_8> > & out);
   virtual void FFTBackward(TArray< complex<r_8> > const & in, TArray< complex<r_8> > & out);
+  virtual r_8  TransfEnergyFFT(TVector< complex<r_8> > const & x, TVector< complex<r_8> > const& fftx
+                              , r_8& A, r_8& B);
+   //! Compute the factor to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
+  virtual inline r_8  TransfEnergyFFT(TVector< complex<r_8> > const & x, TVector< complex<r_8> > const& fftx)
+                      {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
+
   virtual void FFTForward(TArray< r_8 > const & in, TArray< complex<r_8> > & out); 
   virtual void FFTBackward(TArray< complex<r_8> > const & in, TArray< r_8 > & out, 
 			   bool usoutsz=false);
+  virtual r_8  TransfEnergyFFT(TVector< r_8 > const & x, TVector< complex<r_8> > const& fftx
+                              , r_8& A, r_8& B);
+   //! Compute the factor to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
+  virtual inline r_8  TransfEnergyFFT(TVector< r_8 > const & x, TVector< complex<r_8> > const& fftx)
+                      {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
 
   // Transforme N-dim sur des float
   virtual void FFTForward(TArray< complex<r_4> > const & in, TArray< complex<r_4> > & out);
   virtual void FFTBackward(TArray< complex<r_4> > const & in, TArray< complex<r_4> > & out);
+  virtual r_8  TransfEnergyFFT(TVector< complex<r_4> > const & x, TVector< complex<r_4> > const& fftx
+                              , r_8& A, r_8& B);
+   //! Compute the factor to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
+  virtual inline r_8  TransfEnergyFFT(TVector< complex<r_4> > const & x, TVector< complex<r_4> > const& fftx)
+                      {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
+
   virtual void FFTForward(TArray< r_4 > const & in, TArray< complex<r_4> > & out);
   virtual void FFTBackward(TArray< complex<r_4> > const & in, TArray< r_4 > & out,
 			   bool usoutsz=false);
+  virtual r_8  TransfEnergyFFT(TVector< r_4 > const & x, TVector< complex<r_4> > const& fftx
+                              , r_8& A, r_8& B);
+   //! Compute the factor to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
+  virtual inline r_8  TransfEnergyFFT(TVector< r_4 > const & x, TVector< complex<r_4> > const& fftx)
+                      {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
 
  protected:
