Commit 3828e28f by Jean-Eric Campagne

### (JEC) 23/11/15 computation of the Jlnp integral via a combined method: DFBT +...

`(JEC) 23/11/15 computation of the Jlnp integral via a combined method: DFBT + Clenshaw-Curtis quadrature`
parent 7abb5300
 ... ... @@ -121,8 +121,8 @@ CXXHDR = \$(SRC)lagsht_exceptions.h \ \$(SRC)lagSphericTransform.h \ \$(SRC)walltimer.h \ \$(SRC)lagsht_bessel.h \ \$(SRC)laguerre2bessel.h # \$(SRC)quadinteg.h \$(SRC)laguerre2bessel.h \ \$(SRC)quadinteg.h CPPFLAGS += \$(BLASYES) \$(SHARPINC) \$(BLASINC) LDFLAGS += \$(SHARPLIBN) \$(BLASLIBN) -lm ... ...
 ... ... @@ -52,7 +52,7 @@ class LaguerreSphericalTransform { LaguerreSphericalTransform(string spheregeom, int Lmax, int Mmax, int Nmax, r_8 R, int Nrings = -1, int Nphi = -1, int alpha=2): r_8 R, int Nrings = -1, int Nphi = -1, int alpha=2, bool R2tau=true): Lmax_(Lmax), Mmax_(Mmax), R_(R) { //Factory ... ... @@ -68,7 +68,7 @@ class LaguerreSphericalTransform { throw LagSHTError("LaguerreSphericalTransform::Ctor wrong geometry type"); } lagTrans_ = new LaguerreTransform(Nmax, R, alpha); lagTrans_ = new LaguerreTransform(Nmax, R, alpha, R2tau); //JEC 16/11/15 add R2tau //do the map pixelization ... ...
 ... ... @@ -76,8 +76,8 @@ class Bessel { //Helper r_8 operator()(int l, int n) const { if(l>lmax_ || n > nmax_) cout <<" ERROR Besel::Op(l,n) called with ("<
 ... ... @@ -18,7 +18,7 @@ using namespace std; using namespace LagSHT; #define DEBUG 1 #define DEBUG 2 //-------- Parameters set in the main and used in the different test functions struct PARAM { ... ... @@ -233,11 +233,11 @@ void MultiSphericalLaguerreTransform() { #endif vector fijk(NpTot); sphlagtrans.Synthesis(flmnOrig,fijk); #if DEBUG >= 2 //#if DEBUG >= 2 for (int i=0; i(rv,iv); ... ... @@ -341,7 +347,23 @@ void TestLaguerre2Bessel() { }//end loop on shell #if DEBUG >=2 std::copy(flmnOrig.begin(), flmnOrig.end(), std::ostream_iterator< complex >(std::cout, " ")); cout << "F-Lag coeff orig ......... START " << endl; // std::copy(flmnOrig.begin(), flmnOrig.end(), std::ostream_iterator< complex >(std::cout, "\n")); for(int l=0; l > FBlmp(Nalm*Pmax); lag2bess.Lag2BessCoeff(flmnOrig,FBlmp); #if DEBUG >=2 cout << "F-Bessel coeff ......... START " << endl; std::copy(FBlmp.begin(), FBlmp.end(), std::ostream_iterator< complex >(std::cout, "\n")); cout << "F-Bessel coeff ......... END " << endl; #endif cout << "tstack 2b End" < > FLalmk; vector fFLijk; sphlagtrans.Synthesis(flmnOrig,fFLijk,FLalmk); #if DEBUG >=2 cout << "F-Lag fijk coeff ......... START " << endl; std::copy(fFLijk.begin(), fFLijk.end(), std::ostream_iterator< complex >(std::cout, "\n")); cout << "F-Lag fijk coeff ......... END " << endl; #endif cout << "tstack 2d End" <
 ... ... @@ -14,6 +14,7 @@ namespace LagSHT { mais ca n'a pas l'air de converger (28 Sept 15) Version 1: on fait une integration a la Clenshaw-Curtis avec startegie Localeo ou Globale recursive Version 2: Jlnp calcule via une Discrete Fourier-Bessel Transform and a Clenshaw-Curtis quadrature and global integration strategy. */ Laguerre2Bessel::Laguerre2Bessel(BaseGeometry* sphere, LaguerreTransform* lagTrans, ... ... @@ -47,37 +48,54 @@ namespace LagSHT { with r_{lp'} = q_{lp'}/q_{l,PPmax-1}r_{Nmax-1} notice PPmax as nothing to do in principle with Pmax the Fourier-Bessel max value of the 3rd index Kapa_l = q_{l,PPmax-1}/r_{Nmax-1} JEC: 12/11/15 Add the contribution of Integral_{r_{Nmax-1}}^{r_{Nmax-1} + 3(r_{Nmax-1}-r_{Nmax-2})} by Clenshaw-Curtis quadrature */ void Laguerre2Bessel::ComputeJInteg(){ r_8 tau = lagTrans_->GetTau(); r_8 tau3sqrt = pow(tau,(r_8)(3./2.)); cout << "JEC: " << tau3sqrt*sqrt(2.0/M_PI) << endl; r_8 R = Rmax_ / tau; // R = r[N-1] voir acces direct = (lagTrans_->GetNodes()).back() //JEC 12/11/15 Start r_8 rNm1 = Rmax_ / tau; // R = r[N-1] voir acces direct = (lagTrans_->GetNodes()).back() r_8 rNm2 = (lagTrans_->GetNodes())[Nmax_-2]; r_8 deltaR = 3.0 * (rNm1-rNm2); r_8 integLowerBound = rNm1; r_8 integUpperBound = rNm1+deltaR; //for the integral r_8 tol = 1e-10; typedef ClenshawCurtisQuadrature Integrator_t; Integrator_t theQuad(20,"/Users/campagne/Travail/Software/Laguerre/LagSHT/data/ClenshawCurtisRuleData-20.txt",false); //false=do not recompute the weights and nodes of the quadrature Quadrature::values_t integ_val; //JEC 12/11/15 end int Jstride = Lmax_*Pmax_; // nbre of (l,p) couples Jlnp_.resize(Nmax_*Jstride); //JEC 16/11/15 START: Todo all that might be in common somewhere (hint: laguerreTransform.h) int alpha = lagTrans_->GetAlpha(); r_8 alphaFact = 1; // alpha! for(int i=1;i<=alpha; i++) alphaFact *= i; alphaFact = sqrt((r_8)alphaFact); //sqrt(alpha!) r_8 invalphaFact = 1.0/alphaFact; // 1/sqrt(alpha)! vector facts(Nmax_); //sqrt(2/pi)*tau^(3/2)*sqrt(n!/(n+alpha)!) en iteratif vector facts(Nmax_); //sqrt(n!/(n+alpha)!) en iteratif facts[0] = invalphaFact; for(int n=1;n PMax pour la Synthese car appel a qlp int PPmax = 1024; // Sum maximum To be put in parameter int PPmaxm1 = PPmax -1; jnu_ = new Bessel(Lmax_,max(Pmax_,PPmax)); //To do put it in constructor jnu_ = new Bessel(Lmax_,PPmax); //To do put it in constructor tstack_push("J Integ compute "); ... ... @@ -93,7 +111,7 @@ void Laguerre2Bessel::ComputeJInteg(){ r_8 qlpx = (*jnu_)(l,PPmaxm1); //ql,PPmax-1 r_8 Kapa_l = qlpx/R; // Kapa_l = (ql,PPmax-1)/R r_8 Kapa_l = qlpx/rNm1; // Kapa_l = (ql,PPmax-1)/R r_8 Kapa_l3 = Kapa_l * Kapa_l * Kapa_l; r_8 coeff = sqrt(2.0 *M_PI)/Kapa_l3; // Sqrt(2 Pi)/Kapa_l^3 ... ... @@ -102,19 +120,33 @@ void Laguerre2Bessel::ComputeJInteg(){ LaguerreFuncQuad* Ln = new LaguerreFuncQuad(n); r_8 sum = 0.; //contribution of the integral: [0,rNm1] estimated //using Discrete Fourier-Bessel Transform for (int pp=0; ppValue(rlpp); sum += jlqq/(jlp1*jlp1) * Ln->Value(rlpp); }//pp-loop Jlnp_[ploff7 + n*Jstride] = (coeff * sum) * (tau3sqrt*facts[n]); //contribution [rNm1, rNm1+deltaR] estimated with Clenshaw-Curtis quadrature (JEC 12/11/15) Start IntFunc1D f(l,qlp/rNm1,Ln); theQuad.SetFuncBounded(f,integLowerBound,integUpperBound); integ_val = theQuad.GlobalAdapStrat(tol,2,1); Jlnp_[ploff7 + n*Jstride] += integ_val.first * (tau3sqrt*facts[n]*sqrt(2.0/M_PI)); //End ofs < >& FLlmn, int Jstride = Lmax_*Pmax_; std::ofstream ofs; ofs.open ("FBlmp.txt", std::ofstream::out); //try here a pedestrian computation for(int p=0; p >& FLlmn, }//n FBlmp[idBess] = sum; ofs < >& FBlmp, int lmOff7 = l+m*Lmax_-m*(m+1)/2; int id0 = k*Nalm_ + lmOff7; complex sum = 0.; for(int p=0;p sum = 0.; // for(int p=0;p tmp = kapalp*Bessel::jn(l,qlp*rk_red)*FBlmp[id1]; // sum += tmp; // }//loop on p // FBalmk[id0] = sum; }//loop on p FBalmk[id0] += sum; //JEC 18/11/15 Kahan summation algo vector< complex > sumElmt(Pmax_); for(int p=0;p(0.,0.)); }//loop on m }//loop on l ... ... @@ -248,15 +304,15 @@ void Laguerre2Bessel::Synthesis(const vector< complex >& FBlmp, int Ntot3DPix = Npix_*Nmax_; fijk.resize(Ntot3DPix); int off7n, off7k; //perform the synthesis per shell for(int n =0; nalm2map(reinterpret_cast(&(FBalmk.data()[off7n])),&fijk.data()[off7k],false); //the false is to forbidd accumulation sphere_->alm2map(reinterpret_cast(&(FBalmk.data()[off7n])),&fijk.data()[off7k],false); //the false is to forbidd accumulation }//loop on shell }//loop on shell }//Synthesis ... ...
 ... ... @@ -27,12 +27,15 @@ #include #include #include #include //move #include "lagsht_numbers.h" #include "laguerreTransform.h" #include "lagsht_spheregeom.h" #include "lagsht_bessel.h" #include "quadinteg.h" //JEC 12/11/15 using namespace std; namespace LagSHT { ... ... @@ -41,6 +44,28 @@ namespace LagSHT { //// --------- Class to transform Spherical Laguerre into Spherical Bessel -- // //////////////////////////////////////////////////////////////////////////////// //implementation of the Kahan summation algorithm template typename std::iterator_traits::value_type accumulate(InIt begin, InIt end) { typedef typename std::iterator_traits::value_type real; real sum = real(); real running_error = real(); real temp; real difference; for (; begin != end; ++begin) { difference = *begin; difference -= running_error; temp = sum; temp += difference; running_error = temp; running_error -= sum; running_error -= difference; sum = std::move(temp); } return sum; } class Laguerre2Bessel { public: ... ... @@ -87,6 +112,25 @@ private: void ComputeJInteg(); /*! function for numerical integration */ class IntFunc1D : public ClassFunc1D { public: IntFunc1D(int l, r_8 klp,LaguerreFuncQuad* Ln): l_(l),klp_(klp),Ln_(Ln) {} virtual double operator()(double x) const { return (x*x)*(Bessel::jn(l_,x*klp_))*Ln_->Value(x); } virtual ~IntFunc1D() {} private: int l_; r_8 klp_; LaguerreFuncQuad* Ln_; //no ownership };//class IntFunc1D protected: BaseGeometry* sphere_; //
 ... ... @@ -27,13 +27,14 @@ #include //very important for abs definition #include #include #include // std::setprecision #include "lagsht_numbers.h" using namespace std; #define DEBUG 0 #define DEBUG 1 namespace LagSHT { ... ... @@ -206,11 +207,15 @@ protected: weights[k] = x*tmp1/(tmp0*tmp0); }//end for #if DEBUG >= 1 //verification r_16 sumR = 0.; r_16 sumW = 0.; r_16 wip; for (int i=0;i