| 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 | #include "pexceptions.h" | 
|---|
| 9 |  | 
|---|
| 10 |  | 
|---|
| 11 | namespace SOPHYA { | 
|---|
| 12 |  | 
|---|
| 13 | /*!  class of Legendre polynomials  */ | 
|---|
| 14 | class Legendre { | 
|---|
| 15 | public : | 
|---|
| 16 | Legendre(r_8 x, int_4 lmax); | 
|---|
| 17 |  | 
|---|
| 18 | inline r_8 getPl(int_4 l) const | 
|---|
| 19 | { | 
|---|
| 20 | if (l>lmax_)  { | 
|---|
| 21 | throw RangeCheckError("Legendre::getPl(l) l>lmax -> Instanciate class with greater lmax ..."); | 
|---|
| 22 | } | 
|---|
| 23 | return Pl_(l); | 
|---|
| 24 | } | 
|---|
| 25 |  | 
|---|
| 26 | private : | 
|---|
| 27 | Legendre() {;}   // this is forbidden | 
|---|
| 28 |  | 
|---|
| 29 | void array_init(int_4 lmax); | 
|---|
| 30 |  | 
|---|
| 31 | r_8 x_; | 
|---|
| 32 | int_4 lmax_; | 
|---|
| 33 | TVector<r_8> Pl_; | 
|---|
| 34 | }; | 
|---|
| 35 |  | 
|---|
| 36 |  | 
|---|
| 37 |  | 
|---|
| 38 | class LambdaLMBuilder { | 
|---|
| 39 |  | 
|---|
| 40 | public: | 
|---|
| 41 |  | 
|---|
| 42 | LambdaLMBuilder() {} | 
|---|
| 43 | LambdaLMBuilder(r_8 theta,int_4 lmax, int_4 mmax); | 
|---|
| 44 | LambdaLMBuilder(r_8 ct, r_8 st,int_4 lmax, int_4 mmax); | 
|---|
| 45 |  | 
|---|
| 46 | virtual ~LambdaLMBuilder() {}; | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 | //--- Optimisation Reza mai 2006 Serie de fonctions statiques | 
|---|
| 50 | // specialisees/optimisees pour SphericalTransform | 
|---|
| 51 | static void ComputeBmFrAlm(r_8 theta,int_4 lmax, int_4 mmax, | 
|---|
| 52 | const Alm<r_8>& alm, Bm< complex<r_8> >& bm); | 
|---|
| 53 | static void ComputeBmFrAlm(r_8 theta,int_4 lmax, int_4 mmax, | 
|---|
| 54 | const Alm<r_4>& alm, Bm< complex<r_4> >& bm); | 
|---|
| 55 | static void ComputeAlmFrPhase(r_8 theta,int_4 lmax, int_4 mmax, | 
|---|
| 56 | TVector< complex<r_8> >& phase, Alm<r_8> & alm); | 
|---|
| 57 | static void ComputeAlmFrPhase(r_8 theta,int_4 lmax, int_4 mmax, | 
|---|
| 58 | TVector< complex<r_4> >& phase, Alm<r_4> & alm); | 
|---|
| 59 | //---- Fin foctions specialisees | 
|---|
| 60 |  | 
|---|
| 61 | /*! return the value of the coefficient \f$  \lambda_l^m \f$ */ | 
|---|
| 62 | inline double lamlm(int l, int m) const   { | 
|---|
| 63 | return lambda_(l,m); | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 | inline double lamlm(int index) const { | 
|---|
| 67 | return lambda_[index]; | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|
| 70 |  | 
|---|
| 71 | //Return pointer to first element address of the alm's | 
|---|
| 72 | //inline r_8* Data()  {return lambda_.Data();} | 
|---|
| 73 |  | 
|---|
| 74 |  | 
|---|
| 75 | private: | 
|---|
| 76 | static void updateArrayRecurrence(int_4 lmax); | 
|---|
| 77 |  | 
|---|
| 78 | void array_init(int lmax, int mmax); | 
|---|
| 79 |  | 
|---|
| 80 |  | 
|---|
| 81 | // static LowerTriangularMatrix<r_8>* a_recurrence_; | 
|---|
| 82 | static LowerTriangularMatrix<r_8> a_recurrence_; | 
|---|
| 83 | LowerTriangularMatrix<r_8> lambda_; | 
|---|
| 84 |  | 
|---|
| 85 | protected : | 
|---|
| 86 |  | 
|---|
| 87 | void updateArrayLamNorm(); | 
|---|
| 88 |  | 
|---|
| 89 | // static  LowerTriangularMatrix<r_8>* lam_fact_; | 
|---|
| 90 | static  LowerTriangularMatrix<r_8> lam_fact_; | 
|---|
| 91 | static  TVector<r_8>*  normal_l_; | 
|---|
| 92 | int_4 lmax_; | 
|---|
| 93 | int_4 mmax_; | 
|---|
| 94 | r_8 cth_; | 
|---|
| 95 | r_8 sth_; | 
|---|
| 96 |  | 
|---|
| 97 | }; | 
|---|
| 98 |  | 
|---|
| 99 |  | 
|---|
| 100 | class LambdaWXBuilder : public LambdaLMBuilder | 
|---|
| 101 | { | 
|---|
| 102 | public: | 
|---|
| 103 |  | 
|---|
| 104 |  | 
|---|
| 105 | LambdaWXBuilder() {} | 
|---|
| 106 |  | 
|---|
| 107 | LambdaWXBuilder(r_8 theta, int_4 lmax, int_4 mmax); | 
|---|
| 108 |  | 
|---|
| 109 | /*! return the value of the coefficients \f$ _{w}\lambda_l^m\f$ and \f$_{x}\lambda_l^m\f$ */ | 
|---|
| 110 | inline void lam_wx(int l, int m, r_8& w, r_8& x) const | 
|---|
| 111 | { | 
|---|
| 112 | if (m > l ) | 
|---|
| 113 | { | 
|---|
| 114 | throw RangeCheckError("LambdaWXBuilder::lam_wx : l < m !" ); | 
|---|
| 115 | } | 
|---|
| 116 | w=lamWlm_(l,m); | 
|---|
| 117 | x=lamXlm_(l,m); | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | private: | 
|---|
| 121 |  | 
|---|
| 122 | void array_init(); | 
|---|
| 123 |  | 
|---|
| 124 |  | 
|---|
| 125 | LowerTriangularMatrix<r_8> lamWlm_; | 
|---|
| 126 | LowerTriangularMatrix<r_8> lamXlm_; | 
|---|
| 127 |  | 
|---|
| 128 |  | 
|---|
| 129 | }; | 
|---|
| 130 |  | 
|---|
| 131 | class LambdaPMBuilder : public LambdaLMBuilder | 
|---|
| 132 | { | 
|---|
| 133 | public: | 
|---|
| 134 |  | 
|---|
| 135 | LambdaPMBuilder() {} | 
|---|
| 136 |  | 
|---|
| 137 | LambdaPMBuilder(r_8 theta, int_4 lmax, int_4 mmax); | 
|---|
| 138 | /*! return the value of the coefficients \f$ _{+}\lambda_l^m\f$ and \f$_{-}\lambda_l^m\f$ */ | 
|---|
| 139 | inline void lam_pm(int l, int m, r_8& lambda_plus, r_8& lambda_moins) const | 
|---|
| 140 | { | 
|---|
| 141 | if (m > l ) | 
|---|
| 142 | { | 
|---|
| 143 | throw RangeCheckError("LambdaPMBuilder::lam_pm : l < m !" ); | 
|---|
| 144 | } | 
|---|
| 145 | lambda_plus = lamPlm_(l,m); | 
|---|
| 146 | lambda_moins = lamMlm_(l,m); | 
|---|
| 147 | } | 
|---|
| 148 |  | 
|---|
| 149 | private: | 
|---|
| 150 | void array_init(); | 
|---|
| 151 |  | 
|---|
| 152 | LowerTriangularMatrix<r_8> lamPlm_; | 
|---|
| 153 | LowerTriangularMatrix<r_8> lamMlm_; | 
|---|
| 154 |  | 
|---|
| 155 | }; | 
|---|
| 156 |  | 
|---|
| 157 | } // Fin du namespace | 
|---|
| 158 |  | 
|---|
| 159 | #endif | 
|---|