source: Sophya/trunk/SophyaLib/Samba/lambdaBuilder.h@ 748

Last change on this file since 748 was 729, checked in by ansari, 26 years ago

addition des Ylm etc.

File size: 5.8 KB
Line 
1#ifndef LAMBDABUILDER_SEEN
2#define LAMBDABUILDER_SEEN
3
4#include <math.h>
5#include "ndatablock.h"
6#include "tvector.h"
7#include "alm.h"
8
9/*!
10generate Legendre polynomials : use in two steps :
11
12a) 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).
13
14b) get the value of Legendre polynomial for a particular value of \f$l\f$ by calling the method getPl.
15*/
16class Legendre {
17
18 public :
19Legendre();
20Legendre(r_8 x, int_4 lmax);
21 inline r_8 getPl(int_4 l)
22{
23 if (l>lmax_)
24 {
25 throw (" illegal call of Legendre::getPl with index greater than lmax, which Legendre Class was instanciated with : instanciate Legendre with a greater lmax... ");
26 }
27return Pl_(l);
28}
29
30 private :
31 /*! compute all \f$P_l(x,l_{max})\f$ for \f$l=1,l_{max}\f$ */
32 void array_init(int_4 lmax);
33
34 r_8 x_;
35 int_4 lmax_;
36 TVector<r_8> Pl_;
37};
38
39
40
41/*!
42This class generate the coefficients :
43\f[
44 \lambda_l^m=\sqrt{\frac{2l+1}{4\pi}\frac{(l-m)!}{(l+m)!}}
45 P_l^m(\cos{\theta})
46\f]
47where \f$P_l^m\f$ are the associated Legendre polynomials. The above coefficients contain the theta-dependance of spheric harmonics :
48\f[
49 Y_{lm}(\cos{\theta})=\lambda_l^m(\cos{\theta}) e^{im\phi}.
50\f]
51
52Each object has a fixed theta (radians), and maximum l and m to be calculated
53(lmax and mmax).
54 use the class in two steps :
55a) 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).
56b) get the values of coefficients for particular values of \f$l\f$ and \f$m\f$ by calling the method lamlm.
57*/
58 class LambdaLMBuilder {
59
60 public:
61
62LambdaLMBuilder() {}
63LambdaLMBuilder(r_8 theta,int_4 lmax, int_4 mmax);
64 ~LambdaLMBuilder() {};
65
66 /*! return the value of the coefficient \f$ \lambda_l^m \f$ */
67inline double lamlm(int l, int m) const { return lambda_(l,m); }
68
69 private:
70/*! compute a static array of coefficients independant from theta (common to all instances of the LambdaBuilder Class */
71 void updateArrayRecurrence(int_4 lmax);
72
73 void array_init(int lmax, int mmax);
74
75
76 static TriangularMatrix<r_8>* a_recurrence_;
77 TriangularMatrix<r_8> lambda_;
78
79 protected :
80
81/*! compute static arrays of coefficients independant from theta (common to all instances of the derived classes */
82 void updateArrayLamNorm();
83
84 static TriangularMatrix<r_8>* lam_fact_;
85 static TVector<r_8>* normal_l_;
86 int_4 lmax_;
87 int_4 mmax_;
88 r_8 cth_;
89 r_8 sth_;
90
91 };
92
93
94
95/*!
96
97This class generates the coefficients :
98\f[
99 _{w}\lambda_l^m=-2\sqrt{\frac{2(l-2)!}{(l+2)!}\frac{(2l+1)}{4\pi}\frac{(l-m)!}{(l+m)!}} G^+_{lm}
100\f]
101\f[
102 _{x}\lambda_l^m=-2\sqrt{\frac{2(l-2)!}{(l+2)!}\frac{(2l+1)}{4\pi}\frac{(l-m)!}{(l+m)!}}G^-_{lm}
103\f]
104where
105\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})
106\f]
107and
108\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)
109\f]
110 \f$P_l^m\f$ are the associated Legendre polynomials.
111
112The coefficients express the theta-dependance of the \f$W_{lm}(\cos{\theta})\f$ and \f$X_{lm}(\cos{\theta})\f$ functions :
113\f[W_{lm}(\cos{\theta}) = \sqrt{\frac{(l+2)!}{2(l-2)!}}_w\lambda_l^m(\cos{\theta})e^{im\phi}
114\f]
115\f[X_{lm}(\cos{\theta}) = -i\sqrt{\frac{(l+2)!}{2(l-2)!}}_x\lambda_l^m(\cos{\theta})e^{im\phi}
116\f]
117 where \f$W_{lm}(\cos{\theta})\f$ and \f$X_{lm}(\cos{\theta})\f$ are defined as :
118
119\f[
120W_{lm}(\cos{\theta})=-\frac{1}{2}\sqrt{\frac{(l+2)!}{(l-2)!}}\left(
121_{+2}Y_l^m(\cos{\theta})+_{-2}Y_l^m(\cos{\theta})\right)
122\f]
123\f[X_{lm}(\cos{\theta})=-\frac{i}{2}\sqrt{\frac{(l+2)!}{(l-2)!}}\left(
124_{+2}Y_l^m(\cos{\theta})-_{-2}Y_l^m(\cos{\theta})\right)
125\f]
126
127*/
128class LambdaWXBuilder : public LambdaLMBuilder
129{
130 public:
131
132
133LambdaWXBuilder() {}
134
135LambdaWXBuilder(r_8 theta, int_4 lmax, int_4 mmax);
136
137 /*! return the value of the coefficients \f$ _{w}\lambda_l^m\f$ and \f$_{x}\lambda_l^m\f$ */
138inline void lam_wx(int l, int m, r_8& w, r_8& x) const
139 {
140 w=lamWlm_(l,m);
141 x=lamXlm_(l,m);
142 }
143
144 private:
145
146 void array_init();
147
148
149 TriangularMatrix<r_8> lamWlm_;
150 TriangularMatrix<r_8> lamXlm_;
151
152
153};
154
155/*!
156
157This class generates the coefficients
158\f[
159 _{\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)
160\f]
161where
162\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})
163\f]
164and
165\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)
166\f]
167and \f$P_l^m\f$ are the associated Legendre polynomials.
168The coefficients express the theta-dependance of the spin-2 spherical harmonics :
169\f[_{\pm2}Y_l^m(\cos{\theta})=_\pm\lambda_l^m(\cos{\theta})e^{im\phi}
170\f]
171*/
172class LambdaPMBuilder : public LambdaLMBuilder
173{
174 public:
175
176LambdaPMBuilder() {}
177
178 LambdaPMBuilder(r_8 theta, int_4 lmax, int_4 mmax);
179 /*! return the value of the coefficients \f$ _{+}\lambda_l^m\f$ and \f$_{-}\lambda_l^m\f$ */
180inline void lam_pm(int l, int m, r_8& lambda_plus, r_8& lambda_moins) const
181 {
182 lambda_plus = lamPlm_(l,m);
183 lambda_moins = lamMlm_(l,m);
184 }
185
186 private:
187 void array_init();
188
189 TriangularMatrix<r_8> lamPlm_;
190 TriangularMatrix<r_8> lamMlm_;
191
192
193
194};
195
196#endif
Note: See TracBrowser for help on using the repository browser.