| [729] | 1 | #include "alm.h" | 
|---|
|  | 2 | template <class T> | 
|---|
|  | 3 | Alm<T>::Alm(const TVector<T>& clin, const r_8 fwhm) | 
|---|
|  | 4 |  | 
|---|
|  | 5 | { | 
|---|
|  | 6 |  | 
|---|
|  | 7 |  | 
|---|
|  | 8 | /*======================================================================= | 
|---|
|  | 9 | creates the a_lm from the power spectrum, | 
|---|
|  | 10 | assuming they are gaussian  and complex | 
|---|
|  | 11 | with a variance given by C(l) | 
|---|
|  | 12 |  | 
|---|
|  | 13 | the input file should contain : l and C(l) with *consecutive* l's | 
|---|
|  | 14 | (missing C(l) are put to 0.) | 
|---|
|  | 15 |  | 
|---|
|  | 16 | because the map is real we have : a_l-m = (-)^m conjug(a_lm) | 
|---|
|  | 17 | so we actually compute them only for m >= 0 | 
|---|
|  | 18 |  | 
|---|
|  | 19 | =======================================================================*/ | 
|---|
|  | 20 | int_4 nlmax= clin.NElts()-1; | 
|---|
|  | 21 |  | 
|---|
|  | 22 | //alm.ReSize(nlmax); | 
|---|
|  | 23 | ReSizeRow(nlmax+1); | 
|---|
|  | 24 |  | 
|---|
|  | 25 | r_8 sig_smooth = fwhm/sqrt(8.*log(2.))/(60.*180.)* M_PI; | 
|---|
|  | 26 | int_4 n_l = nlmax+1; | 
|---|
|  | 27 |  | 
|---|
|  | 28 |  | 
|---|
|  | 29 | //    --- smoothes the initial power spectrum --- | 
|---|
|  | 30 | TVector<T> cl=clin; | 
|---|
| [833] | 31 | int l; | 
|---|
|  | 32 | for (l=0;l<n_l;l++) | 
|---|
| [729] | 33 | { | 
|---|
|  | 34 | r_8 gauss=exp(-l*(l+1.)*sig_smooth*sig_smooth); | 
|---|
|  | 35 | cl(l)*=(T)gauss; | 
|---|
|  | 36 | } | 
|---|
|  | 37 |  | 
|---|
|  | 38 |  | 
|---|
|  | 39 | //     --- generates randomly the alm according to their power spectrum --- | 
|---|
|  | 40 | r_8 hsqrt2 = 1.0 / Rac2; | 
|---|
|  | 41 |  | 
|---|
| [833] | 42 | for (l=0;l<n_l;l++) | 
|---|
| [729] | 43 | { | 
|---|
|  | 44 | T rms=sqrt(cl(l)); | 
|---|
|  | 45 | //        ------ m = 0 ------ | 
|---|
|  | 46 | complex<T> zeta1(NorRand()); | 
|---|
|  | 47 | (*this)(l,0)   = zeta1 * rms; | 
|---|
|  | 48 |  | 
|---|
|  | 49 | //------ m > 0 ------ | 
|---|
|  | 50 | for (int m=1;m<=l;m++) | 
|---|
|  | 51 | { | 
|---|
|  | 52 | complex<T> aux1(hsqrt2); | 
|---|
|  | 53 | complex<T> aux2(NorRand(),NorRand()); | 
|---|
|  | 54 | zeta1=aux1*aux2; | 
|---|
|  | 55 | (*this)(l,m)=rms*zeta1; | 
|---|
|  | 56 | } | 
|---|
|  | 57 | } | 
|---|
|  | 58 | } | 
|---|
|  | 59 |  | 
|---|
|  | 60 |  | 
|---|
|  | 61 | template <class T> | 
|---|
|  | 62 | TVector<T> Alm<T>::powerSpectrum() const | 
|---|
|  | 63 | { | 
|---|
|  | 64 | int_4 nlmax=Lmax(); | 
|---|
|  | 65 |  | 
|---|
| [1621] | 66 | TVector<T>  powsp(nlmax+1); | 
|---|
| [729] | 67 |  | 
|---|
|  | 68 | for (int l=0; l<=nlmax;l++) | 
|---|
|  | 69 | { | 
|---|
| [1621] | 70 | powsp(l)=( (*this)(l,0) ).real()*( (*this)(l,0) ).real(); | 
|---|
| [729] | 71 | for (int m=1; m<=l; m++) | 
|---|
|  | 72 | { | 
|---|
| [1621] | 73 | powsp(l)+=2.*( (*this)(l,m).real()*(*this)(l,m).real()+ | 
|---|
| [865] | 74 | (*this)(l,m).imag()*(*this)(l,m).imag() ); | 
|---|
| [729] | 75 | } | 
|---|
| [1621] | 76 | powsp(l)/=(2.*l+1.); | 
|---|
| [729] | 77 | } | 
|---|
| [1621] | 78 | return powsp; | 
|---|
| [729] | 79 | } | 
|---|
|  | 80 |  | 
|---|
|  | 81 | #ifdef __CXX_PRAGMA_TEMPLATES__ | 
|---|
|  | 82 | #pragma define_template Alm<r_8> | 
|---|
|  | 83 | #pragma define_template Alm<r_4> | 
|---|
|  | 84 | #endif | 
|---|
|  | 85 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) | 
|---|
|  | 86 | template class Alm<r_8>; | 
|---|
|  | 87 | template class Alm<r_4>; | 
|---|
|  | 88 | #endif | 
|---|