Changeset 3500 in Sophya for trunk/Cosmo
- Timestamp:
- Jun 18, 2008, 6:44:59 PM (17 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/Makefile
r3488 r3500 38 38 # ---- Les programmes de test 39 39 PROGSTEST = \ 40 $(EXE)cmvchkwhu $(EXE)hu_sigma8 40 $(EXE)cmvchkwhu $(EXE)hu_sigma8 $(EXE)cmvsinxsx 41 41 #$(EXE)cmvtluc 42 42 43 43 PROGSTESTOBJ = \ 44 44 $(OBJ)hu_tf_fit.o $(OBJ)hu_power.o \ 45 $(OBJ)cmvtluc.o $(OBJ)cmvchkwhu.o $(OBJ)hu_sigma8.o 45 $(OBJ)cmvtluc.o $(OBJ)cmvchkwhu.o $(OBJ)hu_sigma8.o \ 46 $(OBJ)cmvsinxsx.o 46 47 47 48 #-------------------------------------------------------------------------- … … 240 241 $(OBJ)cmvfitpk.o: cmvfitpk.cc 241 242 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ cmvfitpk.cc 243 244 ############################################################################## 245 cmvsinxsx: $(EXE)cmvsinxsx 246 echo $@ " done" 247 $(EXE)cmvsinxsx: $(OBJ)cmvsinxsx.o $(LIBR) 248 $(CXXLINK) $(CXXREP) -o $@ $(OBJ)cmvsinxsx.o $(MYLIB) 249 $(OBJ)cmvsinxsx.o: cmvsinxsx.cc 250 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ cmvsinxsx.cc 251 252 ############################################################################## -
trunk/Cosmo/SimLSS/geneutils.cc
r3365 r3500 294 294 295 295 //------------------------------------------------------------------- 296 double SinXsX(double x,bool app) 297 // Calcul de sin(x)/x 298 // Approx: dernier terme x^6/(6*20*42) ~ 1e-13 -> x^2 ~ 1.7e-4 299 { 300 double x2 = x*x; 301 if(app || x2<1.7e-4) return 1. - x2/6.*(1. - x2/20.*(1. - x2/42.)); 302 return sin(x)/x; 303 } 304 305 double SinXsX_Sqr(double x,bool app) 306 // Calcul de (sin(x)/x)^2 307 // Approx: dernier terme 2*x^6/(3*15*14) ~ 1e-13 -> x^2 ~ 6.8e-5 308 { 309 double x2 = x*x; 310 if(app || x2<6.8e-5) return 1. - x2/3.*(1. - 2.*x2/15.*(1. - x2/14.)); 311 x2 = sin(x)/x; 312 return x2*x2; 313 } 314 315 double SinNXsX(double x,unsigned long N,bool app) 316 // Calcul de sin(N*x)/sin(x) avec N entier positif 317 // ATTENTION: N est entier 318 // 1. pour que sin(N*x) et sin(x) soient nuls en meme temps 319 // (on peut faire le DL popur sin(N*x) et sin(x)) 320 // 2. pour traiter correctement le DL en x = p*Pi+e avec e<<1 et p entier 321 // sin(N*x)/sin(x) = sin(N*p*Pi+N*e)/sin(p*Pi+e) 322 // = [sin(N*p*Pi)*cos(N*e)+cos(N*p*Pi)*sin(N*e)] 323 // / [sin(p*Pi)*cos(e)+cos(p*Pi)*sin(e)] 324 // comme sin(N*p*Pi)=0 325 // = [cos(N*p*Pi)*sin(N*e)] / [cos(p*Pi)*sin(e)] 326 // = [sin(N*e)/sin(e)] * [cos(N*p*Pi)/cos(p*Pi)] 327 // = [DL autour de x=0] * (+1 ou -1) 328 // Le seul cas ou on a "-1" est quand "p=impair" (cos(p*Pi)=-1) et "N=pair" 329 // Approx: dernier terme x^4*N^4/120 ~ 1e-13 -> x^2 ~ 3.5e-6/N^2 330 { 331 if(N==0) return 0; 332 double sx = sin(x), N2 = N*N; 333 if(app || sx*sx<3.5e-6/N2) { 334 double x2 = asin(sx); x2 *= x2; 335 double s = 1.; 336 if(N%2==0 && cos(x)<0.) s = -1.; // cas x ~ (2p+1)*Pi et N pair 337 return s*N*(1.-(N-1.)*(N+1.)/6.*x2*(1.-(3.*N2-7.)/60.*x2)); 338 } 339 return sin((double)N*x)/sx; 340 } 341 342 double SinNXsX_Sqr(double x,unsigned long N,bool app) 343 // Calcul de [sin(N*x)/sin(x)]^2 avec N entier positif 344 // ATTENTION: cf remarque pour N entier dans SinNXsX 345 // Approx: dernier terme x^4*2*N^4/45 ~ 1e-13 -> x^2 ~ 1.5e-6/N^2 346 { 347 if(N==0) return 0; 348 double sx = sin(x), N2 = N*N; 349 if(app || sx*sx<1.5e-6/N2) { 350 double x2 = asin(sx); x2 *= x2; 351 return N2*(1. - (N-1.)*(N+1.)/3.*x2*(1. - (2.*N2-3.)/15.*x2)); 352 } 353 sx = sin((double)N*x)/sx; 354 return sx*sx; 355 } 356 357 //------------------------------------------------------------------- 296 358 297 359 static unsigned short IntegrateFunc_GlOrder = 0; -
trunk/Cosmo/SimLSS/geneutils.h
r3365 r3500 88 88 double FrAngSol(double angsol); 89 89 90 double SinXsX(double x,bool app=false); 91 double SinXsX_Sqr(double x,bool app=false); 92 93 double SinNXsX(double x,unsigned long N,bool app=false); 94 double SinNXsX_Sqr(double x,unsigned long N,bool app=false); 95 90 96 //---------------------------------------------------- 91 97 double IntegrateFunc(GenericFunc& func,double xmin,double xmax
Note:
See TracChangeset
for help on using the changeset viewer.