| [1371] | 1 | //   Class for representing spherical harmonic coefficients | 
|---|
|  | 2 | //              G. Le Meur      2000 | 
|---|
|  | 3 | // DAPNIA/SPP (Saclay) / CEA    LAL - IN2P3/CNRS  (Orsay) | 
|---|
|  | 4 |  | 
|---|
| [729] | 5 | #ifndef ALM_SEEN | 
|---|
|  | 6 | #define ALM_SEEN | 
|---|
| [758] | 7 |  | 
|---|
| [3613] | 8 | #include "randinterf.h" | 
|---|
| [729] | 9 | #include "nbmath.h" | 
|---|
| [3810] | 10 | #include "trngmtx.h" | 
|---|
| [729] | 11 | #include "tvector.h" | 
|---|
|  | 12 |  | 
|---|
| [1371] | 13 | namespace SOPHYA { | 
|---|
| [729] | 14 |  | 
|---|
| [3510] | 15 | // ----- Classe Alm | 
|---|
| [729] | 16 | template <class T> | 
|---|
| [3810] | 17 | class Alm : public LowerTriangularMatrix< complex<T> > { | 
|---|
| [3510] | 18 | public : | 
|---|
| [729] | 19 |  | 
|---|
| [3810] | 20 | Alm() : LowerTriangularMatrix<complex<T> >()  {} | 
|---|
| [3510] | 21 | //! instanciate the class from the maximum value of the index \f$l\f$ in the sequence of the \f$a_{lm}\f$'s | 
|---|
| [3810] | 22 | Alm(sa_size_t nlmax) : LowerTriangularMatrix<complex<T> >(nlmax+1) {} | 
|---|
| [3510] | 23 | //! copy constructor | 
|---|
| [3810] | 24 | Alm(const Alm<T>& a,  bool share=false)  : LowerTriangularMatrix<complex<T> >(a, share)  {} | 
|---|
| [3510] | 25 | //! Constructor, generates alm from a cl vector | 
|---|
|  | 26 | Alm(const TVector<T> & clin, const r_8 fwhm) ; | 
|---|
|  | 27 | //! Constructor, generates alm from a cl vector, using the specified random generator object | 
|---|
| [3613] | 28 | Alm(const TVector<T> & clin, const r_8 fwhm, RandomGeneratorInterface& rg); | 
|---|
| [729] | 29 |  | 
|---|
| [3510] | 30 | //! Resize with a new lmax | 
|---|
|  | 31 | inline void ReSizeToLmax(sa_size_t nlmax) {this->ReSizeRow(nlmax+1);} | 
|---|
|  | 32 | inline sa_size_t Lmax() const {return this->rowNumber()-1;} | 
|---|
| [729] | 33 |  | 
|---|
| [3510] | 34 | //! Computes the corresponding pwer spectrum (Cl vector) | 
|---|
|  | 35 | TVector<T> powerSpectrum() const; | 
|---|
| [729] | 36 |  | 
|---|
| [3510] | 37 | inline  Alm<T>& SetComplexT(complex<T> a) | 
|---|
|  | 38 | {  this->SetT(a);  return *this;  } | 
|---|
|  | 39 | inline Alm<T>& operator = (complex<T> a) | 
|---|
|  | 40 | {  return SetComplexT(a);  } | 
|---|
|  | 41 |  | 
|---|
|  | 42 | private: | 
|---|
| [3613] | 43 | void GenFromCl(const TVector<T> & clin, const r_8 fwhm, RandomGeneratorInterface& rg); | 
|---|
| [729] | 44 | }; | 
|---|
| [3510] | 45 |  | 
|---|
|  | 46 |  | 
|---|
|  | 47 | //------------ Classe Bm , vecteur avec index  -mMax <= index <= +mMax | 
|---|
| [729] | 48 | template <class T> | 
|---|
| [3510] | 49 | class Bm  { | 
|---|
|  | 50 | public : | 
|---|
|  | 51 | Bm(): nmmax_(0) {;}; | 
|---|
|  | 52 | //! Constructor with the specification of the maximum absolute value of the index : |mMax| | 
|---|
|  | 53 | //! Copy contrsuctor | 
|---|
|  | 54 | Bm(sa_size_t mmax) : nmmax_(mmax)   { bm_.ReSize( (2*mmax+1) );} | 
|---|
|  | 55 | Bm(const Bm<T>& b,  bool share=false) : nmmax_(b.nmmax_), bm_(b.bm_, share) { } | 
|---|
|  | 56 | //! resize with a new value of mmax | 
|---|
|  | 57 | inline void ReSizeToMmax(sa_size_t mmax) | 
|---|
|  | 58 | { nmmax_= mmax; bm_.ReSize(2* nmmax_+1); } | 
|---|
| [729] | 59 |  | 
|---|
| [3510] | 60 | //! Acces to element with index m  ( -mMax <= m <= +mMax  ) | 
|---|
|  | 61 | inline T operator()(sa_size_t m) const { return bm_( m+nmmax_); } | 
|---|
|  | 62 | //! Acces to element with index m  ( -mMax <= m <= +mMax  ) | 
|---|
|  | 63 | inline T& operator()(sa_size_t m) { return bm_( m+nmmax_); } | 
|---|
| [729] | 64 |  | 
|---|
| [3510] | 65 | //! Return the current value of the maximum absolute value of the index | 
|---|
|  | 66 | inline sa_size_t Mmax() const   { return nmmax_; } | 
|---|
| [729] | 67 |  | 
|---|
| [3510] | 68 | inline Bm<T>& operator = (const Bm<T>& b) | 
|---|
|  | 69 | { | 
|---|
|  | 70 | if (this != &b) { | 
|---|
|  | 71 | nmmax_= b.nmmax_; | 
|---|
|  | 72 | bm_=  b.bm_; | 
|---|
|  | 73 | } | 
|---|
|  | 74 | return *this; | 
|---|
|  | 75 | } | 
|---|
| [729] | 76 |  | 
|---|
|  | 77 |  | 
|---|
| [3510] | 78 | private: | 
|---|
|  | 79 | sa_size_t nmmax_; | 
|---|
|  | 80 | NDataBlock<T> bm_; | 
|---|
| [729] | 81 | }; | 
|---|
|  | 82 |  | 
|---|
| [1371] | 83 | } // namespace SOPHYA | 
|---|
| [729] | 84 |  | 
|---|
|  | 85 | #endif | 
|---|