Index: trunk/SophyaPI/PIext/pitvmaad.cc
===================================================================
--- trunk/SophyaPI/PIext/pitvmaad.cc	(revision 3661)
+++ trunk/SophyaPI/PIext/pitvmaad.cc	(revision 3713)
@@ -7,9 +7,45 @@
 #include <math.h>
 
-/* --Methode-- */
-template <class T> 
-POTVectorAdapter<T>::POTVectorAdapter(TVector<T>* v, bool ad)
+// -------------------------------------------------------
+// Decodage de la presence dans la chaine opt des options d'affichage pour tableaux complexes 
+//   cdreal , cdimag , cdphase , cdmod , cdmod2
+PICmplxDispOption StringToCmplxDispOption( string & opt )
+{
+PICmplxDispOption dopt=PICDO_Module;
+size_t olen = opt.length();
+if (opt.find("cdmod2")<olen) dopt=PICDO_Module2;
+else if (opt.find("cdmod")<olen) dopt=PICDO_Module;
+else if (opt.find("cdphas")<olen) dopt=PICDO_Phase;
+else if (opt.find("cdimag")<olen) dopt=PICDO_Imag;
+else if (opt.find("cdreal")<olen) dopt=PICDO_Real;
+else dopt=PICDO_Module;
+return dopt;  
+}
+
+/* --- Methodes de calcul inline pour valeurs de retour complexes ---- */
+static inline double  _z_mod_( complex< r_4 > z) 
+{
+  return ( sqrt((double)(z.real()*z.real()+z.imag()*z.imag() ) ) );
+}
+static inline double  _z_mod_( complex< r_8 > z) 
+{
+  return ( sqrt(z.real()*z.real()+z.imag()*z.imag() )  );
+}
+static inline double  _z_mod2_( complex< r_4 > z) 
+{
+  return ( (double)(z.real()*z.real()+z.imag()*z.imag() ) );
+}
+static inline double  _z_mod2_( complex< r_8 > z) 
+{
+  return ( z.real()*z.real()+z.imag()*z.imag() );
+}
+/* ----------------------------  */
+
+/* --Methode-- */
+template <class T> 
+POTVectorAdapter<T>::POTVectorAdapter(TVector<T>* v, bool ad, PICmplxDispOption dopt)
         : P1DArrayAdapter(v->NElts())
 {
+dOpt = dopt;
 aDel = ad; 
 mVec = v; 
@@ -26,5 +62,5 @@
 double POTVectorAdapter<T>::Value(int i)
 {
-return((*mVec)(i));
+  return((double)(*mVec)(i));
 }
 
@@ -33,8 +69,21 @@
 double POTVectorAdapter< complex<float> >::Value(int i)
 {
-double re,im;
-re = (*mVec)(i).real();
-im = (*mVec)(i).imag();
-return(sqrt(re*re+im*im));
+switch (dOpt) {
+ case PICDO_Module:
+   return _z_mod_( (*mVec)(i) );
+   break;
+ case PICDO_Real:
+   return (double)(((*mVec)(i)).real());
+   break;
+ case PICDO_Imag:
+   return (double)(((*mVec)(i)).imag());
+   break;
+ case PICDO_Phase:
+   return atan2( (double) ((*mVec)(i).real()), (double)((*mVec)(i).imag()) );
+   break;
+ case PICDO_Module2:
+   return _z_mod2_( (*mVec)(i) );
+   break;
+ }
 }
 
@@ -43,15 +92,29 @@
 double POTVectorAdapter< complex<double> >::Value(int i)
 {
-double re,im;
-re = (*mVec)(i).real();
-im = (*mVec)(i).imag();
-return(sqrt(re*re+im*im));
-}
-
-/* --Methode-- */
-template <class T> 
-POTMatrixAdapter<T>::POTMatrixAdapter(TMatrix<T>* mtx, bool ad)
+switch (dOpt) {
+ case PICDO_Module:
+   return _z_mod_( (*mVec)(i) );
+   break;
+ case PICDO_Real:
+   return (double)(((*mVec)(i)).real());
+   break;
+ case PICDO_Imag:
+   return (double)(((*mVec)(i)).imag());
+   break;
+ case PICDO_Phase:
+   return atan2( (double) ((*mVec)(i).real()), (double)((*mVec)(i).imag()) );
+   break;
+ case PICDO_Module2:
+   return _z_mod2_( (*mVec)(i) );
+   break;
+ }
+}
+
+/* --Methode-- */
+template <class T> 
+POTMatrixAdapter<T>::POTMatrixAdapter(TMatrix<T>* mtx, bool ad, PICmplxDispOption dopt)
         : P2DArrayAdapter(mtx->NCols(), mtx->NRows())
 {
+dOpt = dopt;
 aDel = ad; 
 mMtx = mtx;
@@ -89,8 +152,21 @@
 double POTMatrixAdapter< complex<float> >::Value(int ix, int iy)
 {
-double re,im;
-re = (*mMtx)(iy, ix).real();
-im = (*mMtx)(iy, ix).imag();
-return(sqrt(re*re+im*im));
+switch (dOpt) {
+ case PICDO_Module:
+   return _z_mod_( (*mMtx)(iy, ix) );
+   break;
+ case PICDO_Real:
+   return (double)(((*mMtx)(iy, ix)).real());
+   break;
+ case PICDO_Imag:
+   return (double)(((*mMtx)(iy, ix)).imag());
+   break;
+ case PICDO_Phase:
+   return atan2( (double) ((*mMtx)(iy, ix)).real(), (double) ((*mMtx)(iy, ix)).imag() );
+   break;
+ case PICDO_Module2:
+   return _z_mod2_( (*mMtx)(iy, ix) );
+   break;
+ }
 }
 
@@ -99,8 +175,21 @@
 double POTMatrixAdapter< complex<double> >::Value(int ix, int iy)
 {
-double re,im;
-re = (*mMtx)(iy, ix).real();
-im = (*mMtx)(iy, ix).imag();
-return(sqrt(re*re+im*im));
+switch (dOpt) {
+ case PICDO_Module:
+   return _z_mod_( (*mMtx)(iy, ix) );
+   break;
+ case PICDO_Real:
+   return (double)(((*mMtx)(iy, ix)).real());
+   break;
+ case PICDO_Imag:
+   return (double)(((*mMtx)(iy, ix)).imag());
+   break;
+ case PICDO_Phase:
+   return atan2( (double) ((*mMtx)(iy, ix)).real(), (double) ((*mMtx)(iy, ix)).imag() );
+   break;
+ case PICDO_Module2:
+   return _z_mod2_( (*mMtx)(iy, ix) );
+   break;
+ }
 }
 
@@ -112,9 +201,25 @@
 if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; }
 if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; }    
-complex<float> ss = 0.;
+complex<float> ssz = complex<float>(0.,0.);
 for(int j=jy1; j<=jy2; j++) 
-  for(int i=ix1; i<=ix2; i++)  ss += (*mMtx)(j, i);
-ss /= (double)((jy2-jy1+1)*(ix2-ix1+1));
-return sqrt(ss.real()*ss.real()+ss.imag()*ss.imag());  
+  for(int i=ix1; i<=ix2; i++)  ssz += (*mMtx)(j, i);
+switch (dOpt) {
+ case PICDO_Module:
+   return _z_mod_( ssz / complex<float>((float)((jy2-jy1+1)*(ix2-ix1+1)),(float)0.) );
+   break;
+ case PICDO_Real:
+   return ((double)(ssz.real())/(double)((jy2-jy1+1)*(ix2-ix1+1)) ) ;
+   break;
+ case PICDO_Imag:
+   return ((double)(ssz.imag())/(double)((jy2-jy1+1)*(ix2-ix1+1)) ) ;
+   break;
+ case PICDO_Phase:
+   return atan2( (double) ssz.real(), (double) ssz.imag() );
+   break;
+ case PICDO_Module2:
+   return _z_mod2_( ssz / complex<float>((float)((jy2-jy1+1)*(ix2-ix1+1)),(float)0.) );
+   break;
+ }
+return 0.;  
 }   
 
@@ -126,10 +231,30 @@
 if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; }
 if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; }    
-complex<double> ss = 0.;
+complex<double> ssz = complex<double>(0.,0.);
 for(int j=jy1; j<=jy2; j++) 
-  for(int i=ix1; i<=ix2; i++)  ss += (*mMtx)(j, i);
-ss /= (double)((jy2-jy1+1)*(ix2-ix1+1));
-return sqrt(ss.real()*ss.real()+ss.imag()*ss.imag());  
+  for(int i=ix1; i<=ix2; i++)  ssz += (*mMtx)(j, i);
+switch (dOpt) {
+ case PICDO_Module:
+   return _z_mod_( ssz / complex<double>((double)((jy2-jy1+1)*(ix2-ix1+1)),(double)0.) );
+   break;
+ case PICDO_Real:
+   return ((double)(ssz.real())/(double)((jy2-jy1+1)*(ix2-ix1+1)) ) ;
+   break;
+ case PICDO_Imag:
+   return ((double)(ssz.imag())/(double)((jy2-jy1+1)*(ix2-ix1+1)) ) ;
+   break;
+ case PICDO_Phase:
+   return atan2( (double) ssz.real(), (double) ssz.imag() );
+   break;
+ case PICDO_Module2:
+   return _z_mod2_( ssz / complex<double>((double)((jy2-jy1+1)*(ix2-ix1+1)),(double)0.) );
+   break;
+ }
+return 0.;  
 }   
+
+
+
+
 
 #ifdef __CXX_PRAGMA_TEMPLATES__
