| [2615] | 1 | #include "sopnamsp.h" | 
|---|
| [729] | 2 | #include "lambdaBuilder.h" | 
|---|
|  | 3 | #include "nbconst.h" | 
|---|
|  | 4 |  | 
|---|
|  | 5 |  | 
|---|
| [1218] | 6 | /*! | 
|---|
|  | 7 | \class SOPHYA::Legendre | 
|---|
|  | 8 | generate Legendre polynomials : use in two steps : | 
|---|
|  | 9 |  | 
|---|
|  | 10 | a) instanciate Legendre(\f$x\f$, \f$lmax\f$) ; \f$x\f$ is the value for wich Legendre polynomials will be required (usually equal to \f$\cos \theta\f$) and \f$lmax\f$ is the MAXIMUM value of the order of polynomials wich will be required in the following code (all polynomials, from \f$l=0 to lmax\f$, are computed once for all by an iterative formula). | 
|---|
|  | 11 |  | 
|---|
|  | 12 | b) get the value of Legendre polynomial for a particular value of \f$l\f$ by calling the method getPl. | 
|---|
|  | 13 |  | 
|---|
|  | 14 | */ | 
|---|
|  | 15 |  | 
|---|
|  | 16 |  | 
|---|
| [729] | 17 | Legendre::Legendre(r_8 x, int_4 lmax) | 
|---|
|  | 18 | { | 
|---|
| [1428] | 19 | if (fabs(x) > 1. ) | 
|---|
| [729] | 20 | { | 
|---|
|  | 21 | throw RangeCheckError("variable for Legendre polynomials must have modules inferior to 1" ); | 
|---|
|  | 22 | } | 
|---|
|  | 23 | x_ = x; | 
|---|
|  | 24 | array_init(lmax); | 
|---|
|  | 25 | } | 
|---|
| [1218] | 26 |  | 
|---|
|  | 27 | /*! \fn void SOPHYA::Legendre::array_init(int_4 lmax) | 
|---|
|  | 28 |  | 
|---|
|  | 29 | compute all \f$P_l(x,l_{max})\f$ for \f$l=1,l_{max}\f$ | 
|---|
|  | 30 | */ | 
|---|
| [729] | 31 | void Legendre::array_init(int_4 lmax) | 
|---|
|  | 32 | { | 
|---|
|  | 33 | lmax_ = lmax; | 
|---|
|  | 34 | Pl_.ReSize(lmax_+1); | 
|---|
|  | 35 | Pl_(0)=1.; | 
|---|
| [2277] | 36 | if (lmax>0) Pl_(1)=x_; | 
|---|
| [729] | 37 | for (int k=2; k<Pl_.NElts(); k++) | 
|---|
|  | 38 | { | 
|---|
|  | 39 | Pl_(k) = ( (2.*k-1)*x_*Pl_(k-1)-(k-1)*Pl_(k-2) )/k; | 
|---|
|  | 40 | } | 
|---|
|  | 41 | } | 
|---|
|  | 42 |  | 
|---|
| [1756] | 43 | TriangularMatrix<r_8> LambdaLMBuilder::a_recurrence_ = TriangularMatrix<r_8>(); | 
|---|
|  | 44 | TriangularMatrix<r_8> LambdaLMBuilder::lam_fact_     = TriangularMatrix<r_8>(); | 
|---|
| [729] | 45 | TVector<r_8>* LambdaLMBuilder::normal_l_     = NULL; | 
|---|
|  | 46 |  | 
|---|
| [1218] | 47 |  | 
|---|
|  | 48 |  | 
|---|
|  | 49 | /*! \class SOPHYA::LambdaLMBuilder | 
|---|
|  | 50 |  | 
|---|
|  | 51 |  | 
|---|
|  | 52 | This class generate the coefficients : | 
|---|
|  | 53 | \f[ | 
|---|
|  | 54 | \lambda_l^m=\sqrt{\frac{2l+1}{4\pi}\frac{(l-m)!}{(l+m)!}} | 
|---|
|  | 55 | P_l^m(\cos{\theta}) | 
|---|
|  | 56 | \f] | 
|---|
|  | 57 | where \f$P_l^m\f$ are the associated Legendre polynomials.  The above coefficients contain the theta-dependance of spheric harmonics : | 
|---|
|  | 58 | \f[ | 
|---|
|  | 59 | Y_{lm}(\cos{\theta})=\lambda_l^m(\cos{\theta}) e^{im\phi}. | 
|---|
|  | 60 | \f] | 
|---|
|  | 61 |  | 
|---|
|  | 62 | Each object has a fixed theta (radians), and maximum l and m to be calculated | 
|---|
|  | 63 | (lmax and mmax). | 
|---|
|  | 64 | use the class in two steps : | 
|---|
|  | 65 | a) instanciate  LambdaLMBuilder(\f$\theta\f$, \f$lmax\f$, \f$mmax\f$) ;  \f$lmax\f$ and \f$mmax\f$ are  MAXIMUM values for which \f$\lambda_l^m\f$ will be required in the following code (all coefficients, from \f$l=0 to lmax\f$, are computed once for all by an iterative formula). | 
|---|
|  | 66 | b) get the values of coefficients for  particular values of \f$l\f$ and \f$m\f$ by calling the method lamlm. | 
|---|
|  | 67 | */ | 
|---|
|  | 68 |  | 
|---|
|  | 69 |  | 
|---|
| [729] | 70 | LambdaLMBuilder::LambdaLMBuilder(r_8 theta,int_4 lmax, int_4 mmax) | 
|---|
|  | 71 | { | 
|---|
|  | 72 | cth_=cos(theta); | 
|---|
|  | 73 | sth_=sin(theta); | 
|---|
|  | 74 | array_init(lmax, mmax); | 
|---|
|  | 75 | } | 
|---|
| [1683] | 76 | LambdaLMBuilder::LambdaLMBuilder(r_8 costet, r_8 sintet,int_4 lmax, int_4 mmax) | 
|---|
|  | 77 | { | 
|---|
|  | 78 | cth_=costet; | 
|---|
|  | 79 | sth_=sintet; | 
|---|
|  | 80 | array_init(lmax, mmax); | 
|---|
|  | 81 | } | 
|---|
| [729] | 82 | void LambdaLMBuilder::array_init(int lmax, int mmax) | 
|---|
|  | 83 | { | 
|---|
| [2958] | 84 | updateArrayRecurrence(lmax); | 
|---|
|  | 85 |  | 
|---|
| [729] | 86 | lmax_=lmax; | 
|---|
|  | 87 | mmax_=mmax; | 
|---|
|  | 88 | r_8 bignorm2 = 1.e268; // = 1e-20*1.d288 | 
|---|
|  | 89 |  | 
|---|
|  | 90 | lambda_.ReSizeRow(lmax_+1); | 
|---|
|  | 91 |  | 
|---|
|  | 92 | r_8 lam_mm = 1. / sqrt(4.*Pi) *bignorm2; | 
|---|
|  | 93 |  | 
|---|
|  | 94 | for (int m=0; m<=mmax_;m++) | 
|---|
|  | 95 | { | 
|---|
|  | 96 |  | 
|---|
|  | 97 |  | 
|---|
|  | 98 | lambda_(m,m)= lam_mm / bignorm2; | 
|---|
|  | 99 |  | 
|---|
|  | 100 | r_8 lam_0=0.; | 
|---|
|  | 101 | r_8 lam_1=1. /bignorm2 ; | 
|---|
|  | 102 | //      r_8 a_rec = LWK->a_recurr(m,m); | 
|---|
| [1756] | 103 | r_8 a_rec = a_recurrence_(m,m); | 
|---|
| [729] | 104 | r_8 b_rec = 0.; | 
|---|
|  | 105 | for (int l=m+1; l<=lmax_; l++) | 
|---|
|  | 106 | { | 
|---|
|  | 107 | r_8 lam_2 = (cth_*lam_1-b_rec*lam_0)*a_rec; | 
|---|
|  | 108 | lambda_(l,m) = lam_2*lam_mm; | 
|---|
|  | 109 | b_rec=1./a_rec; | 
|---|
|  | 110 | //      a_rec= LWK->a_recurr(l,m); | 
|---|
| [1756] | 111 | a_rec= a_recurrence_(l,m); | 
|---|
| [729] | 112 | lam_0 = lam_1; | 
|---|
|  | 113 | lam_1 = lam_2; | 
|---|
|  | 114 | } | 
|---|
|  | 115 |  | 
|---|
|  | 116 | lam_mm = -lam_mm*sth_* sqrt( (2.*m+3.)/ (2.*m+2.) ); | 
|---|
|  | 117 |  | 
|---|
|  | 118 | } | 
|---|
|  | 119 | } | 
|---|
|  | 120 |  | 
|---|
| [2958] | 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; | 
|---|
| [2966] | 136 | register r_8 lam_0, lam_1, lam_2; | 
|---|
| [729] | 137 |  | 
|---|
| [2966] | 138 | int_4 l, m, k; | 
|---|
| [2958] | 139 |  | 
|---|
|  | 140 | for (m=0; m<=mmax;m++)   { | 
|---|
| [2966] | 141 | const complex<r_8>* almp = alm.columnData(m); | 
|---|
| [2958] | 142 | complex<r_8>* bmp = &(bm(m)); | 
|---|
| [2966] | 143 | r_8* arecp = a_recurrence_.columnData(m); | 
|---|
|  | 144 | *bmp = (lam_mm / bignorm2)*almp[0];  almp++; | 
|---|
| [2958] | 145 |  | 
|---|
|  | 146 | lam_0=0.; | 
|---|
|  | 147 | lam_1=1. /bignorm2 ; | 
|---|
|  | 148 |  | 
|---|
| [2966] | 149 | //    for (l=m+1; l<=lmax; l++) { | 
|---|
|  | 150 | for (k=0; k<lmax-m; k++) { | 
|---|
|  | 151 | lam_2 = (cth*lam_1-lam_0)*arecp[k]; | 
|---|
|  | 152 | lam_0 = lam_1/arecp[k]; | 
|---|
| [2958] | 153 | lam_1 = lam_2; | 
|---|
| [2966] | 154 |  | 
|---|
|  | 155 | *bmp += (lam_2*lam_mm)*almp[k]; | 
|---|
| [2958] | 156 | } | 
|---|
|  | 157 | lam_mm = -lam_mm*sth* sqrt( (2.*m+3.)/ (2.*m+2.) ); | 
|---|
|  | 158 | } | 
|---|
|  | 159 | } | 
|---|
|  | 160 |  | 
|---|
|  | 161 | /*! | 
|---|
|  | 162 | \brief : Specialized/optimized static function for fast spherical harmonic transform. | 
|---|
|  | 163 | */ | 
|---|
|  | 164 | void LambdaLMBuilder::ComputeBmFrAlm(r_8 theta,int_4 lmax, int_4 mmax, | 
|---|
|  | 165 | const Alm<r_4>& alm, Bm< complex<r_4> >& bm) | 
|---|
|  | 166 | { | 
|---|
|  | 167 | Alm<r_8> alm8(alm.Lmax()); | 
|---|
|  | 168 | for(sa_size_t k=0; k<alm8.Size(); k++) | 
|---|
|  | 169 | alm8(k) = complex<r_8>((r_8)alm(k).real() , (r_8)alm(k).imag()); | 
|---|
|  | 170 | Bm< complex<r_8> > bm8(bm.Mmax()); | 
|---|
|  | 171 | ComputeBmFrAlm(theta, lmax, mmax, alm8, bm8); | 
|---|
|  | 172 | for(sa_size_t kk=-bm.Mmax(); kk<=bm.Mmax(); kk++) | 
|---|
|  | 173 | bm(kk)= complex<r_4>((r_4)bm8(kk).real() , (r_4)bm8(kk).imag()); | 
|---|
|  | 174 | return; | 
|---|
|  | 175 | } | 
|---|
|  | 176 |  | 
|---|
|  | 177 |  | 
|---|
|  | 178 | /*! | 
|---|
|  | 179 | \brief : Specialized/optimized static function for fast spherical harmonic transform. | 
|---|
|  | 180 | Computes alm(l,m) = Sum_l>=m [ lambda(l,m) * phase(l,m) ] | 
|---|
|  | 181 | See SphericalTransformServer<T>::carteVersAlm(SphericalMap<T>& map, nlmax, ctcut, alm) | 
|---|
|  | 182 | */ | 
|---|
|  | 183 | void LambdaLMBuilder::ComputeAlmFrPhase(r_8 theta,int_4 lmax, int_4 mmax, | 
|---|
|  | 184 | TVector< complex<r_8> >& phase, Alm<r_8> & alm) | 
|---|
|  | 185 | { | 
|---|
|  | 186 | updateArrayRecurrence(lmax); | 
|---|
|  | 187 | r_8 cth = cos(theta); | 
|---|
|  | 188 | r_8 sth = sin(theta); | 
|---|
|  | 189 |  | 
|---|
|  | 190 | r_8 bignorm2 = 1.e268; // = 1e-20*1.d288 | 
|---|
|  | 191 |  | 
|---|
|  | 192 | r_8 lam_mm = 1. / sqrt(4.*Pi) *bignorm2; | 
|---|
| [2966] | 193 | register r_8 lam_0, lam_1, lam_2; | 
|---|
| [2958] | 194 |  | 
|---|
| [2966] | 195 | int_4 l, m, k; | 
|---|
| [2958] | 196 |  | 
|---|
|  | 197 | for (m=0; m<=mmax;m++)  { | 
|---|
| [2966] | 198 | complex<r_8>* almp = alm.columnData(m); | 
|---|
| [2958] | 199 | complex<r_8>  phi = phase(m); | 
|---|
|  | 200 |  | 
|---|
|  | 201 | *almp += (lam_mm / bignorm2)*phi;    almp++; | 
|---|
|  | 202 |  | 
|---|
|  | 203 | lam_0=0.; | 
|---|
|  | 204 | lam_1=1. /bignorm2 ; | 
|---|
|  | 205 |  | 
|---|
| [2966] | 206 | r_8* arecp = a_recurrence_.columnData(m); | 
|---|
|  | 207 | //    for (l=m+1; l<=lmax; l++)   { | 
|---|
|  | 208 | for (k=0; k<lmax-m; k++) { | 
|---|
|  | 209 | lam_2 = (cth*lam_1-lam_0)*arecp[k]; | 
|---|
|  | 210 | lam_0 = lam_1/arecp[k]; | 
|---|
| [2958] | 211 | lam_1 = lam_2; | 
|---|
| [2966] | 212 |  | 
|---|
|  | 213 | almp[k] += (lam_2*lam_mm) * phi; | 
|---|
| [2958] | 214 | } | 
|---|
|  | 215 | lam_mm = -lam_mm*sth* sqrt( (2.*m+3.)/ (2.*m+2.) ); | 
|---|
|  | 216 | } | 
|---|
|  | 217 | } | 
|---|
|  | 218 |  | 
|---|
|  | 219 | /*! | 
|---|
|  | 220 | \brief : Specialized/optimized static function for fast spherical harmonic transform. | 
|---|
|  | 221 | Computes alm(l,m) = Sum_l>=m [ lambda(l,m) * phase(l,m) ] | 
|---|
|  | 222 | See SphericalTransformServer<T>::carteVersAlm(SphericalMap<T>& map, nlmax, ctcut, alm) | 
|---|
|  | 223 | */ | 
|---|
|  | 224 | void LambdaLMBuilder::ComputeAlmFrPhase(r_8 theta,int_4 lmax, int_4 mmax, | 
|---|
|  | 225 | TVector< complex<r_4> >& phase, Alm<r_4> & alm) | 
|---|
|  | 226 | { | 
|---|
| [2959] | 227 | updateArrayRecurrence(lmax); | 
|---|
|  | 228 | r_8 cth = cos(theta); | 
|---|
|  | 229 | r_8 sth = sin(theta); | 
|---|
|  | 230 |  | 
|---|
|  | 231 | r_8 bignorm2 = 1.e268; // = 1e-20*1.d288 | 
|---|
|  | 232 |  | 
|---|
|  | 233 | r_8 lam_mm = 1. / sqrt(4.*Pi) *bignorm2; | 
|---|
| [2966] | 234 | register r_8 lam_0, lam_1, lam_2; | 
|---|
|  | 235 |  | 
|---|
|  | 236 | int_4 l, m, k; | 
|---|
| [2959] | 237 |  | 
|---|
|  | 238 | for (m=0; m<=mmax;m++)  { | 
|---|
| [2966] | 239 | complex<r_4>* almp = alm.columnData(m); | 
|---|
| [2959] | 240 | complex<r_4>  phi = phase(m); | 
|---|
|  | 241 |  | 
|---|
| [2966] | 242 | *almp += ((r_4)(lam_mm / bignorm2))*phi;    almp++; | 
|---|
| [2959] | 243 |  | 
|---|
|  | 244 | lam_0=0.; | 
|---|
|  | 245 | lam_1=1. /bignorm2 ; | 
|---|
|  | 246 |  | 
|---|
| [2966] | 247 | r_8* arecp = a_recurrence_.columnData(m); | 
|---|
|  | 248 | //    for (l=m+1; l<=lmax; l++)   { | 
|---|
|  | 249 | for (k=0; k<lmax-m; k++) { | 
|---|
|  | 250 | lam_2 = (cth*lam_1-lam_0)*arecp[k]; | 
|---|
|  | 251 | lam_0 = lam_1/arecp[k]; | 
|---|
| [2959] | 252 | lam_1 = lam_2; | 
|---|
| [2966] | 253 |  | 
|---|
|  | 254 | almp[k] += ((r_4)(lam_2*lam_mm)) * phi; | 
|---|
| [2959] | 255 | } | 
|---|
|  | 256 | lam_mm = -lam_mm*sth* sqrt( (2.*m+3.)/ (2.*m+2.) ); | 
|---|
|  | 257 | } | 
|---|
| [2966] | 258 |  | 
|---|
| [2958] | 259 | } | 
|---|
|  | 260 |  | 
|---|
|  | 261 |  | 
|---|
| [2966] | 262 |  | 
|---|
| [1218] | 263 | /*! \fn void  SOPHYA::LambdaLMBuilder::updateArrayRecurrence(int_4 lmax) | 
|---|
|  | 264 |  | 
|---|
|  | 265 | compute a static array of coefficients independant from theta (common to all instances of the LambdaBuilder Class | 
|---|
|  | 266 | */ | 
|---|
| [2966] | 267 |  | 
|---|
| [729] | 268 | void  LambdaLMBuilder::updateArrayRecurrence(int_4 lmax) | 
|---|
|  | 269 | { | 
|---|
| [2958] | 270 | if ( (a_recurrence_.Size() > 0) && (lmax < a_recurrence_.rowNumber()) ) | 
|---|
|  | 271 | return;  // Pas besoin de recalculer le tableau de recurrence | 
|---|
|  | 272 | if (a_recurrence_.Size() > 0)  { | 
|---|
|  | 273 | cout << " WARNING : The classes LambdaXXBuilder will be more efficient " | 
|---|
|  | 274 | << "if instanciated with parameter lmax = maximum value of l index " | 
|---|
|  | 275 | << "which will be needed in the whole application (arrays not " | 
|---|
|  | 276 | << "recomputed) " << endl; | 
|---|
|  | 277 | cout << "   lmax= " << lmax << " previous instanciation with lmax= " | 
|---|
|  | 278 | <<  a_recurrence_.rowNumber()-1 << endl; | 
|---|
|  | 279 | } | 
|---|
|  | 280 |  | 
|---|
| [1756] | 281 | a_recurrence_.ReSizeRow(lmax+1); | 
|---|
| [729] | 282 | for (int m=0; m<=lmax;m++) | 
|---|
|  | 283 | { | 
|---|
| [1756] | 284 | a_recurrence_(m,m) = sqrt( 2.*m +3.); | 
|---|
| [729] | 285 | for (int l=m+1; l<=lmax; l++) | 
|---|
|  | 286 | { | 
|---|
|  | 287 | r_8 fl2 = (l+1.)*(l+1.); | 
|---|
| [1756] | 288 | a_recurrence_(l,m)=sqrt( (4.*fl2-1.)/(fl2-m*m) ); | 
|---|
| [729] | 289 | } | 
|---|
|  | 290 | } | 
|---|
|  | 291 | } | 
|---|
|  | 292 |  | 
|---|
| [1218] | 293 | /*! \fn void  SOPHYA::LambdaLMBuilder::updateArrayLamNorm() | 
|---|
| [729] | 294 |  | 
|---|
| [1218] | 295 | compute  static arrays of coefficients independant from theta (common to all instances of the derived  classes | 
|---|
|  | 296 | */ | 
|---|
| [729] | 297 | void  LambdaLMBuilder::updateArrayLamNorm() | 
|---|
|  | 298 | { | 
|---|
| [1756] | 299 | lam_fact_.ReSizeRow(lmax_+1); | 
|---|
| [729] | 300 | for(int m = 0;m<= lmax_; m++) | 
|---|
|  | 301 | { | 
|---|
|  | 302 | for (int l=m; l<=lmax_; l++) | 
|---|
|  | 303 | { | 
|---|
| [1756] | 304 | lam_fact_(l,m) =2.*(r_8)sqrt( (2.*l+1)*(l+m)*(l-m)/(2.*l-1)  ); | 
|---|
| [729] | 305 | } | 
|---|
|  | 306 | } | 
|---|
|  | 307 | (*normal_l_).ReSize(lmax_+1); | 
|---|
|  | 308 | (*normal_l_)(0)=0.; | 
|---|
|  | 309 | (*normal_l_)(1)=0.; | 
|---|
|  | 310 | for (int l=2; l< (*normal_l_).NElts(); l++) | 
|---|
|  | 311 | { | 
|---|
|  | 312 | (*normal_l_)(l) =(r_8)sqrt( 2./( (l+2)*(l+1)*l*(l-1) ) ); | 
|---|
|  | 313 | } | 
|---|
|  | 314 | } | 
|---|
|  | 315 |  | 
|---|
|  | 316 |  | 
|---|
| [1218] | 317 | /*! \class SOPHYA::LambdaWXBuilder | 
|---|
| [729] | 318 |  | 
|---|
| [1218] | 319 | This class generates the coefficients : | 
|---|
|  | 320 | \f[ | 
|---|
|  | 321 | _{w}\lambda_l^m=-2\sqrt{\frac{2(l-2)!}{(l+2)!}\frac{(2l+1)}{4\pi}\frac{(l-m)!}{(l+m)!}} G^+_{lm} | 
|---|
|  | 322 | \f] | 
|---|
|  | 323 | \f[ | 
|---|
|  | 324 | _{x}\lambda_l^m=-2\sqrt{\frac{2(l-2)!}{(l+2)!}\frac{(2l+1)}{4\pi}\frac{(l-m)!}{(l+m)!}}G^-_{lm} | 
|---|
|  | 325 | \f] | 
|---|
|  | 326 | where | 
|---|
|  | 327 | \f[G^+_{lm}(\cos{\theta})=-\left( \frac{l-m^2}{\sin^2{\theta}}+\frac{1}{2}l\left(l-1\right)\right)P_l^m(\cos{\theta})+\left(l+m\right)\frac{\cos{\theta}}{\sin^2{\theta}}P^m_{l-1}(\cos{\theta}) | 
|---|
|  | 328 | \f] | 
|---|
|  | 329 | and | 
|---|
|  | 330 | \f[G^-_{lm}(\cos{\theta})=\frac{m}{\sin^2{\theta}}\left(\left(l-1\right)\cos{\theta}P^m_l(\cos{\theta})-\left(l+m\right)P^m_{l-1}(\cos{\theta})\right) | 
|---|
|  | 331 | \f] | 
|---|
|  | 332 | \f$P_l^m\f$ are the associated Legendre polynomials. | 
|---|
| [729] | 333 |  | 
|---|
| [1218] | 334 | The coefficients express the theta-dependance of the \f$W_{lm}(\cos{\theta})\f$ and \f$X_{lm}(\cos{\theta})\f$ functions : | 
|---|
|  | 335 | \f[W_{lm}(\cos{\theta}) = \sqrt{\frac{(l+2)!}{2(l-2)!}}_w\lambda_l^m(\cos{\theta})e^{im\phi} | 
|---|
|  | 336 | \f] | 
|---|
|  | 337 | \f[X_{lm}(\cos{\theta}) = -i\sqrt{\frac{(l+2)!}{2(l-2)!}}_x\lambda_l^m(\cos{\theta})e^{im\phi} | 
|---|
|  | 338 | \f] | 
|---|
|  | 339 | where \f$W_{lm}(\cos{\theta})\f$ and \f$X_{lm}(\cos{\theta})\f$ are defined as : | 
|---|
|  | 340 |  | 
|---|
|  | 341 | \f[ | 
|---|
|  | 342 | W_{lm}(\cos{\theta})=-\frac{1}{2}\sqrt{\frac{(l+2)!}{(l-2)!}}\left( | 
|---|
|  | 343 | _{+2}Y_l^m(\cos{\theta})+_{-2}Y_l^m(\cos{\theta})\right) | 
|---|
|  | 344 | \f] | 
|---|
|  | 345 | \f[X_{lm}(\cos{\theta})=-\frac{i}{2}\sqrt{\frac{(l+2)!}{(l-2)!}}\left( | 
|---|
|  | 346 | _{+2}Y_l^m(\cos{\theta})-_{-2}Y_l^m(\cos{\theta})\right) | 
|---|
|  | 347 | \f] | 
|---|
|  | 348 |  | 
|---|
|  | 349 | */ | 
|---|
|  | 350 |  | 
|---|
|  | 351 |  | 
|---|
| [729] | 352 | LambdaWXBuilder::LambdaWXBuilder(r_8 theta, int_4 lmax, int_4 mmax) : LambdaLMBuilder(theta, lmax, mmax) | 
|---|
|  | 353 | { | 
|---|
|  | 354 | array_init(); | 
|---|
|  | 355 | } | 
|---|
|  | 356 |  | 
|---|
|  | 357 |  | 
|---|
|  | 358 | void LambdaWXBuilder::array_init() | 
|---|
|  | 359 | { | 
|---|
| [1756] | 360 | if (lam_fact_.Size() < 1 || normal_l_ == NULL) | 
|---|
| [729] | 361 | { | 
|---|
| [1756] | 362 | //      lam_fact_ = new  TriangularMatrix<r_8>; | 
|---|
| [729] | 363 | normal_l_ = new TVector<r_8>; | 
|---|
|  | 364 | updateArrayLamNorm(); | 
|---|
|  | 365 | } | 
|---|
|  | 366 | else | 
|---|
| [1756] | 367 | if ( lmax_ > lam_fact_.rowNumber()-1  || lmax_ >  (*normal_l_).NElts()-1 ) | 
|---|
| [729] | 368 | { | 
|---|
|  | 369 | updateArrayLamNorm(); | 
|---|
|  | 370 | } | 
|---|
|  | 371 |  | 
|---|
|  | 372 | r_8 one_on_s2  = 1. / (sth_*sth_) ;    // 1/sin^2 | 
|---|
|  | 373 | r_8 c_on_s2    = cth_*one_on_s2; | 
|---|
|  | 374 | lamWlm_.ReSizeRow(lmax_+1); | 
|---|
|  | 375 | lamXlm_.ReSizeRow(lmax_+1); | 
|---|
|  | 376 |  | 
|---|
|  | 377 | // calcul des lambda | 
|---|
|  | 378 | for(int m = 0;m<= mmax_; m++) | 
|---|
|  | 379 | { | 
|---|
|  | 380 | for (int l=m; l<=lmax_; l++) | 
|---|
|  | 381 | { | 
|---|
|  | 382 | lamWlm_(l,m) =  0.; | 
|---|
|  | 383 | lamXlm_(l,m) =  0.; | 
|---|
|  | 384 | } | 
|---|
|  | 385 | } | 
|---|
|  | 386 | for(int l = 2;l<= lmax_; l++) | 
|---|
|  | 387 | { | 
|---|
|  | 388 | r_8 normal_l =  (*normal_l_)(l); | 
|---|
|  | 389 | for (int m=0; m<=l; m++) | 
|---|
|  | 390 | { | 
|---|
|  | 391 | r_8 lam_lm1m = LambdaLMBuilder::lamlm(l-1,m); | 
|---|
|  | 392 | r_8 lam_lm = LambdaLMBuilder::lamlm(l,m); | 
|---|
| [1756] | 393 | r_8 lam_fact_l_m = lam_fact_(l,m); | 
|---|
| [729] | 394 | r_8  a_w =  2. * (l - m*m) * one_on_s2 + l*(l-1.); | 
|---|
|  | 395 | r_8  b_w =  c_on_s2 * lam_fact_l_m; | 
|---|
|  | 396 | r_8  a_x =  2. * cth_ * (l-1.); | 
|---|
|  | 397 | lamWlm_(l,m) =   normal_l * ( a_w * lam_lm - b_w * lam_lm1m ); | 
|---|
|  | 398 | lamXlm_(l,m) = - normal_l * m* one_on_s2* ( a_x * lam_lm - lam_fact_l_m * lam_lm1m ); | 
|---|
|  | 399 | } | 
|---|
|  | 400 | } | 
|---|
|  | 401 |  | 
|---|
|  | 402 | } | 
|---|
|  | 403 |  | 
|---|
| [1218] | 404 | /*!   \class SOPHYA::LambdaPMBuilder | 
|---|
| [729] | 405 |  | 
|---|
| [1218] | 406 | This class generates the coefficients | 
|---|
|  | 407 | \f[ | 
|---|
|  | 408 | _{\pm}\lambda_l^m=2\sqrt{\frac{(l-2)!}{(l+2)!}\frac{(2l+1)}{4\pi}\frac{(l-m)!}{(l+m)!}}\left( G^+_{lm} \mp G^-_{lm}\right) | 
|---|
|  | 409 | \f] | 
|---|
|  | 410 | where | 
|---|
|  | 411 | \f[G^+_{lm}(\cos{\theta})=-\left( \frac{l-m^2}{\sin^2{\theta}}+\frac{1}{2}l\left(l-1\right)\right)P_l^m(\cos{\theta})+\left(l+m\right)\frac{\cos{\theta}}{\sin^2{\theta}}P^m_{l-1}(\cos{\theta}) | 
|---|
|  | 412 | \f] | 
|---|
|  | 413 | and | 
|---|
|  | 414 | \f[G^-_{lm}(\cos{\theta})=\frac{m}{\sin^2{\theta}}\left(\left(l-1\right)\cos{\theta}P^m_l(\cos{\theta})-\left(l+m\right)P^m_{l-1}(\cos{\theta})\right) | 
|---|
|  | 415 | \f] | 
|---|
|  | 416 | and \f$P_l^m\f$ are the associated Legendre polynomials. | 
|---|
|  | 417 | The coefficients express the theta-dependance of the  spin-2 spherical harmonics : | 
|---|
|  | 418 | \f[_{\pm2}Y_l^m(\cos{\theta})=_\pm\lambda_l^m(\cos{\theta})e^{im\phi} | 
|---|
|  | 419 | \f] | 
|---|
|  | 420 | */ | 
|---|
|  | 421 |  | 
|---|
| [729] | 422 | LambdaPMBuilder::LambdaPMBuilder(r_8 theta, int_4 lmax, int_4 mmax) : LambdaLMBuilder(theta, lmax, mmax) | 
|---|
|  | 423 | { | 
|---|
|  | 424 | array_init(); | 
|---|
|  | 425 | } | 
|---|
|  | 426 |  | 
|---|
|  | 427 |  | 
|---|
|  | 428 | void LambdaPMBuilder::array_init() | 
|---|
|  | 429 | { | 
|---|
| [1756] | 430 | if (lam_fact_.Size() < 1 || normal_l_ == NULL) | 
|---|
| [729] | 431 | { | 
|---|
| [1756] | 432 | //      lam_fact_ = new  TriangularMatrix<r_8>; | 
|---|
| [729] | 433 | normal_l_ = new TVector<r_8>; | 
|---|
|  | 434 | updateArrayLamNorm(); | 
|---|
|  | 435 | } | 
|---|
|  | 436 | else | 
|---|
| [1756] | 437 | if ( lmax_ > lam_fact_.rowNumber()-1  || lmax_ >  (*normal_l_).NElts()-1 ) | 
|---|
| [729] | 438 | { | 
|---|
|  | 439 | updateArrayLamNorm(); | 
|---|
|  | 440 | } | 
|---|
|  | 441 |  | 
|---|
|  | 442 | r_8 one_on_s2 = 1. / (sth_*sth_) ; | 
|---|
|  | 443 | r_8 c_on_s2 = cth_*one_on_s2; | 
|---|
|  | 444 | lamPlm_.ReSizeRow(lmax_+1); | 
|---|
|  | 445 | lamMlm_.ReSizeRow(lmax_+1); | 
|---|
|  | 446 |  | 
|---|
|  | 447 | // calcul des lambda | 
|---|
|  | 448 | for(int m = 0;m<= mmax_; m++) | 
|---|
|  | 449 | { | 
|---|
|  | 450 | for (int l=m; l<=lmax_; l++) | 
|---|
|  | 451 | { | 
|---|
|  | 452 | lamPlm_(l,m) =  0.; | 
|---|
|  | 453 | lamMlm_(l,m) =  0.; | 
|---|
|  | 454 | } | 
|---|
|  | 455 | } | 
|---|
|  | 456 |  | 
|---|
|  | 457 | for(int l = 2;l<= lmax_; l++) | 
|---|
|  | 458 | { | 
|---|
|  | 459 | r_8 normal_l =  (*normal_l_)(l); | 
|---|
|  | 460 | for (int m=0; m<=l; m++) | 
|---|
|  | 461 | { | 
|---|
|  | 462 | r_8 lam_lm1m = LambdaLMBuilder::lamlm(l-1,m); | 
|---|
|  | 463 | r_8 lam_lm = LambdaLMBuilder::lamlm(l,m); | 
|---|
| [1756] | 464 | r_8 lam_fact_l_m = lam_fact_(l,m); | 
|---|
| [729] | 465 | r_8  a_w =  2. * (l - m*m) * one_on_s2 + l*(l-1.); | 
|---|
|  | 466 | r_8 f_w =  lam_fact_l_m/(sth_*sth_); | 
|---|
|  | 467 | r_8  c_w =  2*m*(l-1.) * c_on_s2; | 
|---|
|  | 468 |  | 
|---|
|  | 469 | lamPlm_(l,m)  = normal_l * ( -(a_w+c_w) * lam_lm + f_w*( cth_ + m) * lam_lm1m )/Rac2; | 
|---|
|  | 470 | lamMlm_(l,m) = normal_l * ( -(a_w-c_w) * lam_lm + f_w*( cth_ - m) * lam_lm1m )/Rac2; | 
|---|
|  | 471 | } | 
|---|
|  | 472 | } | 
|---|
|  | 473 |  | 
|---|
|  | 474 | } | 
|---|
|  | 475 |  | 
|---|
|  | 476 |  | 
|---|