Changeset 3510 in Sophya for trunk/SophyaLib/Samba/alm.h
- Timestamp:
- Aug 8, 2008, 3:11:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Samba/alm.h
r3077 r3510 6 6 #define ALM_SEEN 7 7 8 #include "s randgen.h"8 #include "stsrand.h" 9 9 #include "nbmath.h" 10 10 #include "triangmtx.h" … … 13 13 namespace SOPHYA { 14 14 15 / *! class for the coefficients \f$a_{lm}\f$ of the development of a function defined on a sphere, in spherical harmonics */15 // ----- Classe Alm 16 16 template <class T> 17 class Alm : public TriangularMatrix<complex<T> > 18 { 19 public : 17 class Alm : public TriangularMatrix< complex<T> > { 18 public : 20 19 21 Alm() : TriangularMatrix<complex<T> >() {;}; 22 /* instanciate the class from the maximum value of the index \f$l\f$ in the sequence of the \f$a_{lm}\f$'s */ 23 Alm(sa_size_t nlmax) : TriangularMatrix<complex<T> >(nlmax+1) {;} 24 Alm(const Alm<T>& a, bool share=false) : TriangularMatrix<complex<T> >(a, share) {;} 20 Alm() : TriangularMatrix<complex<T> >() {} 21 //! instanciate the class from the maximum value of the index \f$l\f$ in the sequence of the \f$a_{lm}\f$'s 22 Alm(sa_size_t nlmax) : TriangularMatrix<complex<T> >(nlmax+1) {} 23 //! copy constructor 24 Alm(const Alm<T>& a, bool share=false) : TriangularMatrix<complex<T> >(a, share) {} 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 28 Alm(const TVector<T> & clin, const r_8 fwhm, RandomGenerator & rg); 25 29 26 Alm(const TVector<T>& clin, const r_8 fwhm) ; 27 /*! resize with a new lmax */ 28 inline void ReSizeToLmax(sa_size_t nlmax) {this->ReSizeRow(nlmax+1);} 29 inline sa_size_t Lmax() const {return this->rowNumber()-1;} 30 TVector<T> powerSpectrum() const; 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;} 31 33 32 inline Alm<T>& SetComplexT(complex<T> a) 33 { 34 this->SetT(a); 35 return *this; 36 } 37 inline Alm<T>& operator = (complex<T> a) 38 { 39 return SetComplexT(a); 40 } 34 //! Computes the corresponding pwer spectrum (Cl vector) 35 TVector<T> powerSpectrum() const; 41 36 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: 43 void GenFromCl(const TVector<T> & clin, const r_8 fwhm, RandomGenerator& rg); 42 44 }; 43 /*! class for a vector with an index running from \f$-m_{max}\f$ to \f$+m_{max}\f$ (then the size of the vector will be actually \f$2m_{max}+1)\f$ */ 45 46 47 //------------ Classe Bm , vecteur avec index -mMax <= index <= +mMax 44 48 template <class T> 45 class Bm 46 { 47 public : 48 Bm(): nmmax_(0) {;}; 49 /* instanciate from the maximum absolute value of the index */ 50 Bm(sa_size_t mmax) : nmmax_(mmax) { bm_.ReSize( (2*mmax+1) );} 51 Bm(const Bm<T>& b, bool share=false) : nmmax_(b.nmmax_), bm_(b.bm_, share) {;} 52 /*! resize with a new value of mmax */ 53 inline void ReSizeToMmax(sa_size_t mmax) 54 { 55 nmmax_= mmax; 56 bm_.ReSize(2* nmmax_+1); 57 } 58 //inline sa_size_t Size() const {return 2*nmmax_+1;}; 59 inline T& operator()(sa_size_t m) {return bm_( adr_i(m));}; 60 inline T const& operator()(sa_size_t m) const {return *(bm_.Begin()+ adr_i(m));}; 61 /*! return the current value of the maximum absolute value of the index */ 62 inline sa_size_t Mmax() const 63 { 64 return nmmax_; 65 } 66 inline Bm<T>& operator = (const Bm<T>& b) 67 { 68 if (this != &b) 69 { 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); } 59 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_); } 64 65 //! Return the current value of the maximum absolute value of the index 66 inline sa_size_t Mmax() const { return nmmax_; } 67 68 inline Bm<T>& operator = (const Bm<T>& b) 69 { 70 if (this != &b) { 70 71 nmmax_= b.nmmax_; 71 72 bm_= b.bm_; 72 } 73 return *this; 74 } 75 76 private: 77 /*! return the address in the array representing the vector */ 78 inline sa_size_t adr_i(sa_size_t i) const 79 { 80 return (i+nmmax_); 81 } 73 } 74 return *this; 75 } 82 76 83 77 84 85 sa_size_t nmmax_; 86 NDataBlock<T> bm_; 87 78 private: 79 sa_size_t nmmax_; 80 NDataBlock<T> bm_; 88 81 }; 89 82
Note:
See TracChangeset
for help on using the changeset viewer.