Changeset 1756 in Sophya for trunk/SophyaLib/Samba
- Timestamp:
- Nov 13, 2001, 4:29:59 PM (24 years ago)
- Location:
- trunk/SophyaLib/Samba
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Samba/alm.h
r1683 r1756 19 19 public : 20 20 21 Alm() : TriangularMatrix<complex<T> >() { };21 Alm() : TriangularMatrix<complex<T> >() {;}; 22 22 /* instanciate the class from the maximum value of the index \f$l\f$ in the sequence of the \f$a_{lm}\f$'s */ 23 23 Alm(int nlmax) : TriangularMatrix<complex<T> >(nlmax+1) {;} -
trunk/SophyaLib/Samba/lambdaBuilder.cc
r1683 r1756 40 40 } 41 41 42 TriangularMatrix<r_8> * LambdaLMBuilder::a_recurrence_ = NULL;43 TriangularMatrix<r_8> * LambdaLMBuilder::lam_fact_ = NULL;42 TriangularMatrix<r_8> LambdaLMBuilder::a_recurrence_ = TriangularMatrix<r_8>(); 43 TriangularMatrix<r_8> LambdaLMBuilder::lam_fact_ = TriangularMatrix<r_8>(); 44 44 TVector<r_8>* LambdaLMBuilder::normal_l_ = NULL; 45 45 … … 81 81 void LambdaLMBuilder::array_init(int lmax, int mmax) 82 82 { 83 if (a_recurrence_ == NULL)84 { 85 a_recurrence_ = new TriangularMatrix<r_8>;83 if (a_recurrence_.Size() == 0) 84 { 85 // a_recurrence_ = new TriangularMatrix<r_8>; 86 86 updateArrayRecurrence(lmax); 87 87 } 88 88 else 89 if ( lmax > ( *a_recurrence_).rowNumber()-1 )89 if ( lmax > (a_recurrence_).rowNumber()-1 ) 90 90 { 91 91 cout << " WARNING : The classes LambdaXXBuilder will be more efficient if instanciated with parameter lmax = maximum value of l index which will be needed in the whole application (arrays not recomputed) " << endl; 92 cout << "lmax= " << lmax << " previous instanciation with lmax= " << ( *a_recurrence_).rowNumber() << endl;92 cout << "lmax= " << lmax << " previous instanciation with lmax= " << (a_recurrence_).rowNumber() << endl; 93 93 updateArrayRecurrence(lmax); 94 94 } … … 110 110 r_8 lam_1=1. /bignorm2 ; 111 111 // r_8 a_rec = LWK->a_recurr(m,m); 112 r_8 a_rec = (*a_recurrence_)(m,m);112 r_8 a_rec = a_recurrence_(m,m); 113 113 r_8 b_rec = 0.; 114 114 for (int l=m+1; l<=lmax_; l++) … … 118 118 b_rec=1./a_rec; 119 119 // a_rec= LWK->a_recurr(l,m); 120 a_rec= (*a_recurrence_)(l,m);120 a_rec= a_recurrence_(l,m); 121 121 lam_0 = lam_1; 122 122 lam_1 = lam_2; … … 135 135 void LambdaLMBuilder::updateArrayRecurrence(int_4 lmax) 136 136 { 137 (*a_recurrence_).ReSizeRow(lmax+1);137 a_recurrence_.ReSizeRow(lmax+1); 138 138 for (int m=0; m<=lmax;m++) 139 139 { 140 (*a_recurrence_)(m,m) = sqrt( 2.*m +3.);140 a_recurrence_(m,m) = sqrt( 2.*m +3.); 141 141 for (int l=m+1; l<=lmax; l++) 142 142 { 143 143 r_8 fl2 = (l+1.)*(l+1.); 144 (*a_recurrence_)(l,m)=sqrt( (4.*fl2-1.)/(fl2-m*m) );144 a_recurrence_(l,m)=sqrt( (4.*fl2-1.)/(fl2-m*m) ); 145 145 } 146 146 } … … 153 153 void LambdaLMBuilder::updateArrayLamNorm() 154 154 { 155 (*lam_fact_).ReSizeRow(lmax_+1);155 lam_fact_.ReSizeRow(lmax_+1); 156 156 for(int m = 0;m<= lmax_; m++) 157 157 { 158 158 for (int l=m; l<=lmax_; l++) 159 159 { 160 (*lam_fact_)(l,m) =2.*(r_8)sqrt( (2.*l+1)*(l+m)*(l-m)/(2.*l-1) );160 lam_fact_(l,m) =2.*(r_8)sqrt( (2.*l+1)*(l+m)*(l-m)/(2.*l-1) ); 161 161 } 162 162 } … … 214 214 void LambdaWXBuilder::array_init() 215 215 { 216 if (lam_fact_ == NULL|| normal_l_ == NULL)217 { 218 lam_fact_ = new TriangularMatrix<r_8>;216 if (lam_fact_.Size() < 1 || normal_l_ == NULL) 217 { 218 // lam_fact_ = new TriangularMatrix<r_8>; 219 219 normal_l_ = new TVector<r_8>; 220 220 updateArrayLamNorm(); 221 221 } 222 222 else 223 if ( lmax_ > (*lam_fact_).rowNumber()-1 || lmax_ > (*normal_l_).NElts()-1 )223 if ( lmax_ > lam_fact_.rowNumber()-1 || lmax_ > (*normal_l_).NElts()-1 ) 224 224 { 225 225 updateArrayLamNorm(); … … 247 247 r_8 lam_lm1m = LambdaLMBuilder::lamlm(l-1,m); 248 248 r_8 lam_lm = LambdaLMBuilder::lamlm(l,m); 249 r_8 lam_fact_l_m = (*lam_fact_)(l,m);249 r_8 lam_fact_l_m = lam_fact_(l,m); 250 250 r_8 a_w = 2. * (l - m*m) * one_on_s2 + l*(l-1.); 251 251 r_8 b_w = c_on_s2 * lam_fact_l_m; … … 284 284 void LambdaPMBuilder::array_init() 285 285 { 286 if (lam_fact_ == NULL|| normal_l_ == NULL)287 { 288 lam_fact_ = new TriangularMatrix<r_8>;286 if (lam_fact_.Size() < 1 || normal_l_ == NULL) 287 { 288 // lam_fact_ = new TriangularMatrix<r_8>; 289 289 normal_l_ = new TVector<r_8>; 290 290 updateArrayLamNorm(); 291 291 } 292 292 else 293 if ( lmax_ > (*lam_fact_).rowNumber()-1 || lmax_ > (*normal_l_).NElts()-1 )293 if ( lmax_ > lam_fact_.rowNumber()-1 || lmax_ > (*normal_l_).NElts()-1 ) 294 294 { 295 295 updateArrayLamNorm(); … … 318 318 r_8 lam_lm1m = LambdaLMBuilder::lamlm(l-1,m); 319 319 r_8 lam_lm = LambdaLMBuilder::lamlm(l,m); 320 r_8 lam_fact_l_m = (*lam_fact_)(l,m);320 r_8 lam_fact_l_m = lam_fact_(l,m); 321 321 r_8 a_w = 2. * (l - m*m) * one_on_s2 + l*(l-1.); 322 322 r_8 f_w = lam_fact_l_m/(sth_*sth_); -
trunk/SophyaLib/Samba/lambdaBuilder.h
r1683 r1756 60 60 61 61 62 static TriangularMatrix<r_8>* a_recurrence_; 62 // static TriangularMatrix<r_8>* a_recurrence_; 63 static TriangularMatrix<r_8> a_recurrence_; 63 64 TriangularMatrix<r_8> lambda_; 64 65 … … 67 68 void updateArrayLamNorm(); 68 69 69 static TriangularMatrix<r_8>* lam_fact_; 70 // static TriangularMatrix<r_8>* lam_fact_; 71 static TriangularMatrix<r_8> lam_fact_; 70 72 static TVector<r_8>* normal_l_; 71 73 int_4 lmax_; -
trunk/SophyaLib/Samba/sphericaltransformserver.cc
r1715 r1756 154 154 { 155 155 /*======================================================================= 156 computes a map f orm its alm for the HEALPIX pixelisation156 computes a map from its alm for the HEALPIX pixelisation 157 157 map(theta,phi) = sum_l_m a_lm Y_lm(theta,phi) 158 158 = sum_m {e^(i*m*phi) sum_l a_lm*lambda_lm(theta)} … … 167 167 int_4 nmmax=nlmax; 168 168 int_4 nsmax=0; 169 // le Resize est suppose mettre a zero 169 170 map.Resize(pixelSizeIndex); 170 171 char* sphere_type=map.TypeOfMap(); 172 int premiereTranche = 0; 173 int derniereTranche = map.NbThetaSlices()-1; 171 174 if (strncmp(sphere_type,"RING",4) == 0) 172 173 174 175 { 176 nsmax=map.SizeIndex(); 177 } 175 178 else 179 { 176 180 // pour une sphere Gorski le nombre de pixels est 12*nsmax**2 177 181 // on calcule une quantite equivalente a nsmax pour la sphere-theta-phi … … 179 183 // c'est approximatif ; a raffiner. 180 184 if (strncmp(sphere_type,"TETAFI",6) == 0) 181 { 182 nsmax=(int_4)sqrt(map.NbPixels()/12.); 183 } 185 { 186 nsmax=(int_4)sqrt(map.NbPixels()/12.); 187 premiereTranche++; 188 derniereTranche--; 189 } 184 190 else 185 186 187 188 191 { 192 cout << " unknown type of sphere : " << sphere_type << endl; 193 throw IOExc(" unknown type of sphere: " + (string)sphere_type ); 194 } 189 195 // cout << "GenerateFromAlm: the sphere is of type : " << sphere_type << endl; 190 196 // cout << "GenerateFromAlm: size index (nside) of the sphere= " << nsmax << endl; 191 197 // cout << "GenerateFromAlm: nlmax (from Alm) = " << nlmax << endl; 192 if (nlmax>3*nsmax-1)193 {198 // if (nlmax>3*nsmax-1) 199 // { 194 200 // cout << "GenerateFromAlm: nlmax should be <= 3*nside-1" << endl; 195 if (strncmp(sphere_type,"TETAFI",6) == 0) 196 { 197 cout << "GenerateFromAlm: nlmax should be <= 3*nside-1" << endl; 198 cout << " (for this criterium, nsmax is computed as sqrt(nbPixels/12))" << endl; 199 } 200 } 201 // if (strncmp(sphere_type,"TETAFI",6) == 0) 202 // { 203 // cout << "GenerateFromAlm: nlmax should be <= 3*nside-1" << endl; 204 // cout << " (for this criterium, nsmax is computed as sqrt(nbPixels/12))" << endl; 205 // } 206 //} 207 } 201 208 Bm<complex<T> > b_m_theta(nmmax); 202 209 … … 205 212 206 213 // pour chaque tranche en theta 207 for (int_4 ith = 0; ith < map.NbThetaSlices();ith++)214 for (int_4 ith = premiereTranche; ith <= derniereTranche;ith++) 208 215 { 209 216 int_4 nph; … … 231 238 } 232 239 } 233 234 240 // obtains the negative m of b(m,theta) (= complex conjugate) 235 241 … … 377 383 // si phi0 n'est pas nul, il y a juste un decalage a faire. 378 384 //********************************************************************** 379 380 385 TVector< complex<T> > bw(nph); 381 386 TVector< complex<T> > dataout(nph); … … 410 415 411 416 TVector<T> sortie; 412 413 417 fftIntfPtr_-> FFTBackward(data, sortie); 414 418 … … 419 423 /*! \fn Alm<T> SOPHYA::SphericalTransformServer::DecomposeToAlm(const SphericalMap<T>& map, int_4 nlmax, r_8 cos_theta_cut) const 420 424 421 \return the Alm coefficients from analysis of a temperature map. THE MAP CAN BE MODIFIED (if iterationOrder >0)425 \return the Alm coefficients from analysis of a temperature map. 422 426 423 427 \param<nlmax> : maximum value of the l index … … 425 429 \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. 426 430 427 \param<iterationOrder> : 1,2,3,4.... order of an iterative analysis. (Default : 0 -> standard analysis) 428 */ 431 */ 432 template<class T> 433 void SphericalTransformServer<T>::DecomposeToAlm(const SphericalMap<T>& map, Alm<T>& alm, int_4 nlmax, r_8 cos_theta_cut) const 434 { 435 DecomposeToAlm(const_cast< SphericalMap<T>& >(map), alm, nlmax, cos_theta_cut, 0); 436 } 437 //******************************************* 438 439 /*! \fn Alm<T> SOPHYA::SphericalTransformServer::DecomposeToAlm(const SphericalMap<T>& map, int_4 nlmax, r_8 cos_theta_cut, int iterationOrder) const 440 441 \return the Alm coefficients from analysis of a temperature map. THE MAP CAN BE MODIFIED (if iterationOrder >0) 442 443 \param<nlmax> : maximum value of the l index 444 445 \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. 446 447 \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 ! */ 429 448 template<class T> 430 449 void SphericalTransformServer<T>::DecomposeToAlm(SphericalMap<T>& map, Alm<T>& alm, int_4 nlmax, r_8 cos_theta_cut, int iterationOrder) const … … 606 625 throw PException("bizarre : vecteur datain de longueur nulle (CFromFourierAnalysis)"); 607 626 } 608 if (nph%2 != 0 )609 {610 throw PException("SphericalTransformServer<T>::CFromFourierAnalysis : longueur de datain impair ?");611 }627 // if (nph%2 != 0 ) 628 // { 629 // throw PException("SphericalTransformServer<T>::CFromFourierAnalysis : longueur de datain impair ?"); 630 // } 612 631 TVector<complex<T> > transformedData; 613 632 614 633 // la taille du vecteur complexe retourne est nph/2+1 (si la taille 615 634 // du vecteur reel entre est nph) 635 // cout << " longueur de datain = " << nph << endl; 616 636 fftIntfPtr_-> FFTForward(datain, transformedData); 617 637 // cout << " taille de la transformee " << transformedData.Size() << endl; 618 638 // TVector< complex<T> > dataout(nmmax+1); 619 639 dataout.ReSize(nmmax+1); … … 732 752 // mapFromPM(nlmax, nmmax, mapq, mapu, alme, almb); 733 753 } 734 735 736 754 /*! \fn void SOPHYA::SphericalTransformServer::DecomposeToAlm(const SphericalMap<T>& mapq, 737 755 const SphericalMap<T>& mapu, … … 749 767 750 768 \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. 769 770 771 */ 772 template<class T> 773 void SphericalTransformServer<T>::DecomposeToAlm(const SphericalMap<T>& mapq, 774 const SphericalMap<T>& mapu, 775 Alm<T>& alme, 776 Alm<T>& almb, 777 int_4 nlmax, 778 r_8 cos_theta_cut) const 779 { 780 DecomposeToAlm(const_cast< SphericalMap<T>& >(mapq), const_cast< SphericalMap<T>& >(mapu), alme, almb, nlmax, cos_theta_cut); 781 } 782 783 /*! \fn void SOPHYA::SphericalTransformServer::DecomposeToAlm(const SphericalMap<T>& mapq, 784 const SphericalMap<T>& mapu, 785 Alm<T>& alme, 786 Alm<T>& almb, 787 int_4 nlmax, 788 r_8 cos_theta_cut, 789 int iterationOrder) const 790 791 analysis of a polarization map into Alm coefficients. 792 793 The spheres \c mapq and \c mapu contain respectively the Stokes parameters. 794 795 \c a2lme and \c a2lmb will receive respectively electric and magnetic Alm's 796 nlmax : maximum value of the l index 797 798 \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. 799 800 \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 ! 801 802 THE INPUT MAPS CAN BE MODIFIED (only if iterationOrder >0) 803 751 804 */ 752 805 template<class T> … … 1243 1296 1244 1297 1245 /*! \fn TVector<T> SOPHYA::SphericalTransformServer::DecomposeToCl( const SphericalMap<T>& sph, int_4 nlmax, r_8 cos_theta_cut) const1298 /*! \fn TVector<T> SOPHYA::SphericalTransformServer::DecomposeToCl(SphericalMap<T>& sph, int_4 nlmax, r_8 cos_theta_cut, int iterationOrder) const 1246 1299 1247 1300 \return power spectrum from analysis of a temperature map. THE MAP CAN BE MODIFIED (if iterationOrder >0) … … 1251 1304 \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. 1252 1305 1253 \param<iterationOrder> : 1,2,3,4.... order of an iterative analysis. (Default : 0 -> standard analysis)1306 \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 ! 1254 1307 1255 1308 */ … … 1259 1312 Alm<T> alm; 1260 1313 DecomposeToAlm( sph, alm, nlmax, cos_theta_cut, iterationOrder); 1261 // cout << " SphericalTransformServer : impression alm " << endl; 1262 // alm.Print(); 1314 // power spectrum 1315 return alm.powerSpectrum(); 1316 } 1317 1318 1319 /*! \fn TVector<T> SOPHYA::SphericalTransformServer::DecomposeToCl(const SphericalMap<T>& sph, int_4 nlmax, r_8 cos_theta_cut) const 1320 1321 \return power spectrum from analysis of a temperature map. 1322 1323 \param<nlmax> : maximum value of the l index 1324 1325 \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. 1326 1327 1328 */ 1329 1330 1331 template <class T> 1332 TVector<T> SphericalTransformServer<T>::DecomposeToCl(const SphericalMap<T>& sph, int_4 nlmax, r_8 cos_theta_cut) const 1333 { 1334 Alm<T> alm; 1335 DecomposeToAlm( sph, alm, nlmax, cos_theta_cut); 1263 1336 // power spectrum 1264 1337 return alm.powerSpectrum(); -
trunk/SophyaLib/Samba/sphericaltransformserver.h
r1683 r1756 46 46 47 47 48 void DecomposeToAlm(SphericalMap<T>& map, Alm<T>& alm, int_4 nlmax, r_8 cos_theta_cut, int iterationOrder = 0) const; 48 void DecomposeToAlm(SphericalMap<T>& map, Alm<T>& alm, int_4 nlmax, r_8 cos_theta_cut, int iterationOrder) const; 49 void DecomposeToAlm(const SphericalMap<T>& map, Alm<T>& alm, int_4 nlmax, r_8 cos_theta_cut) const; 49 50 50 51 void DecomposeToAlm(SphericalMap<T>& mapq, … … 54 55 int_4 nlmax, 55 56 r_8 cos_theta_cut, 56 int iterationOrder = 0) const; 57 int iterationOrder) const; 58 void DecomposeToAlm(const SphericalMap<T>& mapq, 59 const SphericalMap<T>& mapu, 60 Alm<T>& alme, 61 Alm<T>& almb, 62 int_4 nlmax, 63 r_8 cos_theta_cut) const; 57 64 58 65 TVector<T> DecomposeToCl(SphericalMap<T>& sph, 59 int_4 nlmax, r_8 cos_theta_cut, int iterationOrder = 0) const; 66 int_4 nlmax, r_8 cos_theta_cut, int iterationOrder) const; 67 68 TVector<T> DecomposeToCl(const SphericalMap<T>& sph, 69 int_4 nlmax, r_8 cos_theta_cut) const; 60 70 61 71
Note:
See TracChangeset
for help on using the changeset viewer.