Changeset 2958 in Sophya for trunk/SophyaLib/Samba/lambdaBuilder.cc
- Timestamp:
- Jun 1, 2006, 1:34:50 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Samba/lambdaBuilder.cc
r2615 r2958 82 82 void LambdaLMBuilder::array_init(int lmax, int mmax) 83 83 { 84 if (a_recurrence_.Size() == 0) 85 { 86 // a_recurrence_ = new TriangularMatrix<r_8>; 87 updateArrayRecurrence(lmax); 88 } 89 else 90 if ( lmax > (a_recurrence_).rowNumber()-1 ) 91 { 92 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; 93 cout << "lmax= " << lmax << " previous instanciation with lmax= " << (a_recurrence_).rowNumber() << endl; 94 updateArrayRecurrence(lmax); 95 } 84 updateArrayRecurrence(lmax); 85 96 86 lmax_=lmax; 97 87 mmax_=mmax; … … 129 119 } 130 120 121 /*! 122 \brief : Specialized/optimized static function for fast spherical harmonic transform. 123 Computes bm(m) = Sum_l>=m [ lambda(l,m) * alm(l,m) ] 124 See SphericalTransformServer<T>::GenerateFromAlm(map, pixsize, alm) 125 */ 126 void LambdaLMBuilder::ComputeBmFrAlm(r_8 theta,int_4 lmax, int_4 mmax, 127 const Alm<r_8>& alm, Bm< complex<r_8> >& bm) 128 { 129 updateArrayRecurrence(lmax); 130 r_8 cth = cos(theta); 131 r_8 sth = sin(theta); 132 133 r_8 bignorm2 = 1.e268; // = 1e-20*1.d288 134 135 r_8 lam_mm = 1. / sqrt(4.*Pi) *bignorm2; 136 r_8 lam_0, lam_1, lam_2; 137 register r_8 a_rec, b_rec; 138 139 const complex<r_8>* almp = alm.columnData(0); 140 r_8* arecp = a_recurrence_.columnData(0); 141 142 int_4 l, m; 143 144 for (m=0; m<=mmax;m++) { 145 //MOV^ const complex<r_8>* almp = alm.columnData(m); 146 complex<r_8>* bmp = &(bm(m)); 147 148 *bmp = (lam_mm / bignorm2)*(*almp); almp++; 149 150 lam_0=0.; 151 lam_1=1. /bignorm2 ; 152 153 a_rec = *arecp; arecp++; // a_recurrence_(m,m); 154 b_rec = 0.; 155 for (l=m+1; l<=lmax; l++) { 156 lam_2 = (cth*lam_1-b_rec*lam_0)*a_rec; 157 158 //DEL lambda_(l,m) = lam_2*lam_mm; 159 *bmp += lam_2*lam_mm*(*almp); almp++; 160 b_rec=1./a_rec; 161 // a_rec= LWK->a_recurr(l,m); 162 a_rec= *arecp; arecp++; // a_recurrence_(l,m); 163 lam_0 = lam_1; 164 lam_1 = lam_2; 165 } 166 lam_mm = -lam_mm*sth* sqrt( (2.*m+3.)/ (2.*m+2.) ); 167 } 168 } 169 170 /*! 171 \brief : Specialized/optimized static function for fast spherical harmonic transform. 172 */ 173 void LambdaLMBuilder::ComputeBmFrAlm(r_8 theta,int_4 lmax, int_4 mmax, 174 const Alm<r_4>& alm, Bm< complex<r_4> >& bm) 175 { 176 Alm<r_8> alm8(alm.Lmax()); 177 for(sa_size_t k=0; k<alm8.Size(); k++) 178 alm8(k) = complex<r_8>((r_8)alm(k).real() , (r_8)alm(k).imag()); 179 Bm< complex<r_8> > bm8(bm.Mmax()); 180 ComputeBmFrAlm(theta, lmax, mmax, alm8, bm8); 181 for(sa_size_t kk=-bm.Mmax(); kk<=bm.Mmax(); kk++) 182 bm(kk)= complex<r_4>((r_4)bm8(kk).real() , (r_4)bm8(kk).imag()); 183 return; 184 } 185 186 187 /*! 188 \brief : Specialized/optimized static function for fast spherical harmonic transform. 189 Computes alm(l,m) = Sum_l>=m [ lambda(l,m) * phase(l,m) ] 190 See SphericalTransformServer<T>::carteVersAlm(SphericalMap<T>& map, nlmax, ctcut, alm) 191 */ 192 void LambdaLMBuilder::ComputeAlmFrPhase(r_8 theta,int_4 lmax, int_4 mmax, 193 TVector< complex<r_8> >& phase, Alm<r_8> & alm) 194 { 195 updateArrayRecurrence(lmax); 196 r_8 cth = cos(theta); 197 r_8 sth = sin(theta); 198 199 r_8 bignorm2 = 1.e268; // = 1e-20*1.d288 200 201 r_8 lam_mm = 1. / sqrt(4.*Pi) *bignorm2; 202 r_8 lam_0, lam_1, lam_2; 203 register r_8 a_rec, b_rec; 204 205 complex<r_8>* almp = alm.columnData(0); 206 r_8* arecp = a_recurrence_.columnData(0); 207 208 int_4 l, m; 209 for (m=0; m<=mmax;m++) { 210 //MOV^ complex<r_8>* almp = alm.columnData(m); 211 complex<r_8> phi = phase(m); 212 213 *almp += (lam_mm / bignorm2)*phi; almp++; 214 215 lam_0=0.; 216 lam_1=1. /bignorm2 ; 217 218 //MOV^ r_8* arecp = a_recurrence_.columnData(m); 219 a_rec = *arecp; arecp++; // a_recurrence_(m,m); 220 b_rec = 0.; 221 for (l=m+1; l<=lmax; l++) { 222 lam_2 = (cth*lam_1-b_rec*lam_0)*a_rec; 223 224 //DEL lambda_(l,m) = lam_2*lam_mm; 225 *almp += (lam_2*lam_mm) * phi; 226 almp++; 227 228 b_rec=1./a_rec; 229 // a_rec= LWK->a_recurr(l,m); 230 a_rec= *arecp; arecp++; // a_recurrence_(l,m); 231 lam_0 = lam_1; 232 lam_1 = lam_2; 233 } 234 lam_mm = -lam_mm*sth* sqrt( (2.*m+3.)/ (2.*m+2.) ); 235 } 236 } 237 238 /*! 239 \brief : Specialized/optimized static function for fast spherical harmonic transform. 240 Computes alm(l,m) = Sum_l>=m [ lambda(l,m) * phase(l,m) ] 241 See SphericalTransformServer<T>::carteVersAlm(SphericalMap<T>& map, nlmax, ctcut, alm) 242 */ 243 void LambdaLMBuilder::ComputeAlmFrPhase(r_8 theta,int_4 lmax, int_4 mmax, 244 TVector< complex<r_4> >& phase, Alm<r_4> & alm) 245 { 246 TVector< complex<r_8> > phase8; 247 phase8 = phase; 248 Alm<r_8> alm8(alm.Lmax()); 249 ComputeAlmFrPhase(theta, lmax, mmax, phase8, alm8); 250 for(sa_size_t k=0; k<alm.Size(); k++) 251 alm(k) = complex<r_4>((r_4)alm8(k).real() , (r_4)alm8(k).imag()); 252 return; 253 } 254 131 255 132 256 /*! \fn void SOPHYA::LambdaLMBuilder::updateArrayRecurrence(int_4 lmax) … … 136 260 void LambdaLMBuilder::updateArrayRecurrence(int_4 lmax) 137 261 { 262 if ( (a_recurrence_.Size() > 0) && (lmax < a_recurrence_.rowNumber()) ) 263 return; // Pas besoin de recalculer le tableau de recurrence 264 if (a_recurrence_.Size() > 0) { 265 cout << " WARNING : The classes LambdaXXBuilder will be more efficient " 266 << "if instanciated with parameter lmax = maximum value of l index " 267 << "which will be needed in the whole application (arrays not " 268 << "recomputed) " << endl; 269 cout << " lmax= " << lmax << " previous instanciation with lmax= " 270 << a_recurrence_.rowNumber()-1 << endl; 271 } 272 138 273 a_recurrence_.ReSizeRow(lmax+1); 139 274 for (int m=0; m<=lmax;m++)
Note:
See TracChangeset
for help on using the changeset viewer.