Index: trunk/SophyaLib/Samba/sphericaltransformserver.cc
===================================================================
--- trunk/SophyaLib/Samba/sphericaltransformserver.cc	(revision 1715)
+++ trunk/SophyaLib/Samba/sphericaltransformserver.cc	(revision 1756)
@@ -154,5 +154,5 @@
 {
   /*=======================================================================
-    computes a map form its alm for the HEALPIX pixelisation
+    computes a map from its alm for the HEALPIX pixelisation
     map(theta,phi) = sum_l_m a_lm Y_lm(theta,phi)
     = sum_m {e^(i*m*phi) sum_l a_lm*lambda_lm(theta)}
@@ -167,11 +167,15 @@
   int_4 nmmax=nlmax;
   int_4 nsmax=0;
+  // le Resize est suppose mettre a zero
   map.Resize(pixelSizeIndex);
   char* sphere_type=map.TypeOfMap();
+      int premiereTranche = 0;
+      int derniereTranche = map.NbThetaSlices()-1;
   if (strncmp(sphere_type,"RING",4) == 0)
-    {
-      nsmax=map.SizeIndex();
-    }
+  {
+    nsmax=map.SizeIndex();
+  }
   else
+  {
     // pour une sphere Gorski le nombre de pixels est 12*nsmax**2
     // on calcule une quantite equivalente a nsmax pour la sphere-theta-phi
@@ -179,24 +183,27 @@
     // c'est approximatif ; a raffiner.
     if (strncmp(sphere_type,"TETAFI",6) == 0)
-      {
-	nsmax=(int_4)sqrt(map.NbPixels()/12.);
-      }
+    {
+      nsmax=(int_4)sqrt(map.NbPixels()/12.);
+      premiereTranche++;
+      derniereTranche--;
+    }
     else
-      {
-	cout << " unknown type of sphere : " << sphere_type << endl;
-	throw IOExc(" unknown type of sphere: " + (string)sphere_type );
-      }
+    {
+      cout << " unknown type of sphere : " << sphere_type << endl;
+      throw IOExc(" unknown type of sphere: " + (string)sphere_type );
+    }
   //  cout << "GenerateFromAlm: the sphere is of type : " << sphere_type << endl;
   //  cout << "GenerateFromAlm: size index (nside) of the sphere= " << nsmax << endl;
   //  cout << "GenerateFromAlm: nlmax (from Alm) = " << nlmax << endl;
-  if (nlmax>3*nsmax-1) 
-    {
+  //  if (nlmax>3*nsmax-1) 
+  //  {
       //     cout << "GenerateFromAlm: nlmax should be <= 3*nside-1" << endl;
-      if (strncmp(sphere_type,"TETAFI",6) == 0)
-	{
-	  cout << "GenerateFromAlm: nlmax should be <= 3*nside-1" << endl;
-	  cout << " (for this criterium, nsmax is computed as sqrt(nbPixels/12))" << endl;
-	}
-    }
+  //   if (strncmp(sphere_type,"TETAFI",6) == 0)
+  //	{
+  //	  cout << "GenerateFromAlm: nlmax should be <= 3*nside-1" << endl;
+  //	  cout << " (for this criterium, nsmax is computed as sqrt(nbPixels/12))" << endl;
+  //	}
+  //}
+  }
   Bm<complex<T> > b_m_theta(nmmax);
 
@@ -205,5 +212,5 @@
 
   // pour chaque tranche en theta
-  for (int_4 ith = 0; ith < map.NbThetaSlices();ith++)
+  for (int_4 ith = premiereTranche; ith <= derniereTranche;ith++)
     {
       int_4 nph;
@@ -231,5 +238,4 @@
 	    }
 	}
-
     //        obtains the negative m of b(m,theta) (= complex conjugate)
 
@@ -377,5 +383,4 @@
   // si phi0 n'est pas nul, il y a juste un decalage a faire.
   //**********************************************************************
-
   TVector< complex<T> > bw(nph);
   TVector< complex<T> > dataout(nph);
@@ -410,5 +415,4 @@
 
   TVector<T> sortie;
-
   fftIntfPtr_-> FFTBackward(data, sortie);
   
@@ -419,5 +423,5 @@
  /*! \fn  Alm<T> SOPHYA::SphericalTransformServer::DecomposeToAlm(const SphericalMap<T>& map, int_4 nlmax, r_8 cos_theta_cut) const
 
-\return the Alm coefficients from analysis of a temperature map. THE MAP CAN BE MODIFIED (if iterationOrder >0) 
+\return the Alm coefficients from analysis of a temperature map. 
 
     \param<nlmax> : maximum value of the l index
@@ -425,6 +429,21 @@
      \param<cos_theta_cut> : cosinus of the symmetric cut EULER angle theta : cos_theta_cut=0 means no cut ; cos_theta_cut=1 all the sphere is cut.
 
-\param<iterationOrder> : 1,2,3,4.... order of an iterative analysis. (Default : 0 -> standard analysis)
-  */ 
+ */ 
+template<class T>
+void SphericalTransformServer<T>::DecomposeToAlm(const SphericalMap<T>& map, Alm<T>& alm, int_4 nlmax, r_8 cos_theta_cut) const
+{
+  DecomposeToAlm(const_cast< SphericalMap<T>& >(map), alm, nlmax, cos_theta_cut, 0);
+}
+//*******************************************
+
+ /*! \fn  Alm<T> SOPHYA::SphericalTransformServer::DecomposeToAlm(const SphericalMap<T>& map, int_4 nlmax, r_8 cos_theta_cut, int iterationOrder) const
+
+\return the Alm coefficients from analysis of a temperature map. THE MAP CAN BE MODIFIED (if iterationOrder >0)
+
+    \param<nlmax> : maximum value of the l index
+
+     \param<cos_theta_cut> : cosinus of the symmetric cut EULER angle theta : cos_theta_cut=0 means no cut ; cos_theta_cut=1 all the sphere is cut.
+
+\param<iterationOrder> : 1,2,3,4.... order of an iterative analysis. (Default : 0 -> standard analysis). If iterationOrder is not null, the method works with SphereHEALPix but NOT WITH SphereThetaPhi maps !  */ 
 template<class T>
 void SphericalTransformServer<T>::DecomposeToAlm(SphericalMap<T>& map, Alm<T>& alm, int_4 nlmax, r_8 cos_theta_cut, int iterationOrder) const
@@ -606,14 +625,15 @@
       throw PException("bizarre : vecteur datain de longueur nulle (CFromFourierAnalysis)");
     }
-  if (nph%2 != 0 )
-    {
-      throw PException("SphericalTransformServer<T>::CFromFourierAnalysis : longueur de datain impair ?");
-    }
+  // if (nph%2 != 0 )
+  //  {
+      //  throw PException("SphericalTransformServer<T>::CFromFourierAnalysis : longueur de datain impair ?");
+  //  }
   TVector<complex<T> > transformedData;
 
   // la taille du vecteur complexe retourne est nph/2+1 (si la taille 
   // du vecteur reel entre est nph)
+  //   cout << " longueur de datain  = " << nph << endl;
   fftIntfPtr_-> FFTForward(datain, transformedData);
-
+  //  cout <<  " taille de la transformee " << transformedData.Size() << endl;
   //  TVector< complex<T> > dataout(nmmax+1);
   dataout.ReSize(nmmax+1);
@@ -732,6 +752,4 @@
     // mapFromPM(nlmax, nmmax, mapq, mapu, alme, almb);
 }
-
-
  /*! \fn void SOPHYA::SphericalTransformServer::DecomposeToAlm(const SphericalMap<T>& mapq,
 					      const SphericalMap<T>& mapu,
@@ -749,4 +767,39 @@
 
  \c cos_theta_cut : cosinus of the symmetric cut EULER angle theta : cos_theta_cut=0 means no cut ; cos_theta_cut=1 all the sphere is cut.
+
+
+ */ 
+template<class T>
+void SphericalTransformServer<T>::DecomposeToAlm(const SphericalMap<T>& mapq,
+					      const SphericalMap<T>& mapu,
+					      Alm<T>& alme,
+					      Alm<T>& almb,
+					      int_4 nlmax,
+					      r_8 cos_theta_cut) const
+{
+  DecomposeToAlm(const_cast< SphericalMap<T>& >(mapq), const_cast< SphericalMap<T>& >(mapu), alme, almb, nlmax, cos_theta_cut);
+}
+
+ /*! \fn void SOPHYA::SphericalTransformServer::DecomposeToAlm(const SphericalMap<T>& mapq,
+					      const SphericalMap<T>& mapu,
+					      Alm<T>& alme,
+					      Alm<T>& almb,
+					      int_4 nlmax,
+					      r_8 cos_theta_cut,
+					      int iterationOrder) const
+
+analysis of a polarization map into Alm coefficients.
+
+ The spheres \c mapq and \c mapu contain respectively the Stokes parameters. 
+
+ \c a2lme and \c a2lmb will receive respectively electric and magnetic Alm's
+    nlmax : maximum value of the l index
+
+ \c cos_theta_cut : cosinus of the symmetric cut EULER angle theta : cos_theta_cut=0 means no cut ; cos_theta_cut=1 all the sphere is cut.
+
+\param<iterationOrder> : 1,2,3,4.... order of an iterative analysis. (Default : 0 -> standard analysis). If iterationOrder is not null, the method works with SphereHEALPix but NOT WITH SphereThetaPhi maps !
+
+THE INPUT MAPS CAN BE MODIFIED (only if iterationOrder >0)
+
  */ 
 template<class T>
@@ -1243,5 +1296,5 @@
 
 
-/*! \fn TVector<T>  SOPHYA::SphericalTransformServer::DecomposeToCl(const SphericalMap<T>& sph, int_4 nlmax, r_8 cos_theta_cut) const
+/*! \fn TVector<T>  SOPHYA::SphericalTransformServer::DecomposeToCl(SphericalMap<T>& sph, int_4 nlmax, r_8 cos_theta_cut, int iterationOrder) const
 
 \return power spectrum from analysis of a temperature map. THE MAP CAN BE MODIFIED (if iterationOrder >0) 
@@ -1251,5 +1304,5 @@
      \param<cos_theta_cut> : cosinus of the symmetric cut EULER angle theta : cos_theta_cut=0 means no cut ; cos_theta_cut=1 all the sphere is cut.
 
-\param<iterationOrder> : 1,2,3,4.... order of an iterative analysis. (Default : 0 -> standard analysis)
+\param<iterationOrder> : 1,2,3,4.... order of an iterative analysis. If iterationOrder is not null, the method works with SphereHEALPix but NOT WITH SphereThetaPhi maps !
 
   */ 
@@ -1259,6 +1312,26 @@
   Alm<T> alm;
   DecomposeToAlm( sph, alm, nlmax, cos_theta_cut, iterationOrder);
-    //    cout << " SphericalTransformServer : impression alm " << endl;
-    //     alm.Print();
+  // power spectrum
+     return  alm.powerSpectrum();
+}
+
+
+/*! \fn TVector<T>  SOPHYA::SphericalTransformServer::DecomposeToCl(const SphericalMap<T>& sph, int_4 nlmax, r_8 cos_theta_cut) const
+
+\return power spectrum from analysis of a temperature map. 
+
+     \param<nlmax> : maximum value of the l index
+
+     \param<cos_theta_cut> : cosinus of the symmetric cut EULER angle theta : cos_theta_cut=0 means no cut ; cos_theta_cut=1 all the sphere is cut.
+
+
+  */ 
+
+
+template <class T>
+TVector<T>  SphericalTransformServer<T>::DecomposeToCl(const SphericalMap<T>& sph, int_4 nlmax, r_8 cos_theta_cut) const
+{
+  Alm<T> alm;
+  DecomposeToAlm( sph, alm, nlmax, cos_theta_cut);
   // power spectrum
      return  alm.powerSpectrum();
