#include #include "syn2fast.h" #include "lambuilder.h" #include "fftserver.h" #ifdef __MWERKS__ #include "unixmac.h" #endif extern "C" { // void fft_gpd_(long double* ,int& ,int& ,int& ,int& ,long double*); float gasdev2_(int& idum); } void a2lm2map(const int nsmax,const int nlmax,const int nmmax, const vector< vector< complex > >&alme, const vector< vector< complex > >&almb, vector& mapq, vector& mapu, vector< complex > b_northp, vector< complex > b_southp, vector< complex > bwp, vector< complex > b_northm, vector< complex > b_southm, vector< complex > bwm){ /*======================================================================= computes a map form its alm for the HEALPIX pixelisation map(theta,phi) = sum_l_m a_lm Y_lm(theta,phi) = sum_m {e^(i*m*phi) sum_l a_lm*lambda_lm(theta)} where Y_lm(theta,phi) = lambda(theta) * e^(i*m*phi) * the recurrence of Ylm is the standard one (cf Num Rec) * the sum over m is done by FFT =======================================================================*/ vector< complex > mapp; vector< complex > mapm; //convert the alm from e/b to +/- complex im(0,1); vector< vector< complex > >almp=alme; vector< vector< complex > >almm=almb; for (int i=0;i<(signed) almp.size();i++){ for (int j=0;j<(signed) almp[i].size();j++){ almp[i][j]=-(alme[i][j]+im*almb[i][j]); almm[i][j]=-(alme[i][j]-im*almb[i][j]); } } //for (int i=0;i<(signed) almp.size();i++){cout<m (lambda_l_m(theta) * a_l_m) ------------------------------------------------------ lambda_mm tends to go down when m increases (risk of underflow) lambda_lm tends to go up when l increases (risk of overflow)*/ Lambda2Builder l2b(acos(cth),nlmax,nmmax); for (int m = 0; m <= nmmax; m++){ complex b_np,b_sp,b_nm,b_sm; // cout < shit(b_northp[-m+nmmax].real(),-b_northp[-m+nmmax].imag()); complex shit2(b_southp[-m+nmmax].real(),-b_southp[-m+nmmax].imag()); shit*=fac; shit2*=fac; b_northm[m+nmmax] = shit; b_southm[m+nmmax] = shit2; shit=complex(b_northm[-m+nmmax].real(),-b_northm[-m+nmmax].imag()); shit2=complex(b_southm[-m+nmmax].real(),-b_southm[-m+nmmax].imag()); shit*=fac; shit2*=fac; b_northp[m+nmmax] = shit; b_southp[m+nmmax] = shit2; } // for (int i=0;i<2*nmmax+1;i++){ cout<< b_northp[i]<<" "< f(phi,theta) ---------------------------------------------------------------*/ syn2_phas(nsmax,nlmax,nmmax,b_northp,nph,mapp,istart_north,kphi0,bwp); // north hemisph. + equator syn2_phas(nsmax,nlmax,nmmax,b_northm,nph,mapm,istart_north,kphi0,bwm); istart_north = istart_north + nph; if (ith < 2*nsmax){ istart_south=istart_south-nph; syn2_phas(nsmax,nlmax,nmmax,b_southp,nph,mapp,istart_south,kphi0,bwp); // south hemisph. w/o equat syn2_phas(nsmax,nlmax,nmmax,b_southm,nph,mapm,istart_south,kphi0,bwm); } } for (int i=0;i< (signed)mapp.size();i++){ //cout << mapp[i]<<" "< >& datain, int nph,vector< complex >& dataout, const int start, int kphi0, vector< complex >& bw){ /*======================================================================= dataout(j) = sum_m datain(m) * exp(i*m*phi(j)) with phi(j) = j*2pi/nph + kphi0*pi/nph and kphi0 =0 or 1 as the set of frequencies {m} is larger than nph, we wrap frequencies within {0..nph-1} ie m = k*nph + m' with m' in {0..nph-1} then noting bw(m') = exp(i*m'*phi0) * sum_k (datain(k*nph+m') exp(i*k*pi*kphi0)) with bw(nph-m') = CONJ(bw(m')) (if datain(-m) = CONJ(datain(m))) dataout(j) = sum_m' [ bw(m') exp (i*j*m'*2pi/nph) ] = Fourier Transform of bw is real NB nph is not necessarily a power of 2 =======================================================================*/ int ksign = 1; complex* data= new complex[4*nsmax]; for (int iw=0;iw shit(pow(kshift,k)); bw[iw]+=datain[i-1]*shit;//complex number } // kshift**k = 1 for even turn numbers // = 1 or -1 for odd turn numbers : results from the shift in space // applies the shift in position <-> phase factor in Fourier space for (int iw=1;iw<=nph;iw++){ int m=ksign*(iw-1); complex shit(cos(m*phi0),sin(m*phi0)); data[iw-1]=bw[iw-1]*shit; } for (int i = nph; i< 4*nsmax;i++){ data[i] = 0; } //cout< > >& a2lme, vector< vector< complex > >& a2lmb, vector& cls_e, vector& cls_b, int& iseed,const float fwhm, vector lread){ /*======================================================================= creates the a_lm from the power spectrum, assuming they are gaussian and complex with a variance given by C(l) the input file should contain : l and C(l) with *consecutive* l's (missing C(l) are put to 0.) because the map is real we have : a_l-m = (-)^m conjug(a_lm) so we actually compute them only for m >= 0 modifie G. Le Meur (13/01/98) : on ne lit plus les C(l) sur un fichier. Le tableau est entre en argument (cls_tt). Ce tableau doit contenir les valeur de C(l) par ordre SEQUENTIEL de l (de l=0 a l=nlmax) =======================================================================*/ /* CHARACTER*128 filename integer unit,n_l,j,il,im real fs,quadrupole,xxxtmp,correct real fs_tt real zeta1_r, zeta1_i LOGICAL ok character*20 string_quad real*4 prefact(0:2) logical prefact_bool integer lneffct real gasdev2 external lneffct, gasdev2 c-----------------------------------------------------------------------*/ a2lme.resize(nlmax+1); a2lmb.resize(nlmax+1); for (int i=0; i< (signed) a2lme.size();i++){ a2lme[i].resize(nmmax+1); a2lmb[i].resize(nmmax+1); } iseed = -abs(iseed); if (iseed == 0){iseed=-1;} int idum = iseed; float sig_smooth = fwhm/sqrt(8.*log(2.))/(60.*180.)* M_PI; for (int i=0;i