Changeset 3595 in Sophya
- Timestamp:
- Apr 19, 2009, 2:47:10 PM (16 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/cmvsinxsx.cc
r3572 r3595 12 12 /* 13 13 ...Check autour de zero 14 > cmvsinxsx -n 4 1e-6,-0.1,0.115 > cmvsinxsx -n 5 1e-6,-0.1,0.114 > cmvsinxsx -n 4 -x 1e-6,-0.1,0.1 15 > cmvsinxsx -n 5 -x 1e-6,-0.1,0.1 16 16 ...Check autour de Pi 17 > cmvsinxsx -n 4 1e-6,3.041592659,3.24159265918 > cmvsinxsx -n 5 1e-6,3.041592659,3.24159265917 > cmvsinxsx -n 4 -x 1e-6,3.041592659,3.241592659 18 > cmvsinxsx -n 5 -x 1e-6,3.041592659,3.241592659 19 19 ...Check autour de -Pi 20 > cmvsinxsx -n 4 1e-6,-3.241592659,-3.04159265921 > cmvsinxsx -n 5 1e-6,-3.241592659,-3.04159265920 > cmvsinxsx -n 4 -x 1e-6,-3.241592659,-3.041592659 21 > cmvsinxsx -n 5 -x 1e-6,-3.241592659,-3.041592659 22 22 23 23 ...Check longue echelle 24 > cmvsinxsx -n 10 0.0001,-6.5,6.525 > cmvsinxsx -n 11 0.0001,-6.5,6.524 > cmvsinxsx -n 10 -x 0.0001,-6.5,6.5 25 > cmvsinxsx -n 11 -x 0.0001,-6.5,6.5 26 26 27 27 ...Check sans plot 28 > cmvsinxsx -n 100 0.00001,-6.5,6.5 29 > cmvsinxsx -n 1000 0.00001,-6.5,6.5 28 > cmvsinxsx -n 100 -x 0.00001,-6.5,6.5 29 > cmvsinxsx -n 1000 -x 0.00001,-6.5,6.5 30 31 ...Check general 32 > cmvsinxsx -n 20 -p 1e-8 -v 65536,-2.,0. -x -1,-20.,20. 30 33 */ 31 34 … … 34 37 { 35 38 double dt = 0.000001; 36 //double tmin = -0.1, tmax = 0.1;37 double tmin = M_PI-0.1, tmax = M_PI+0.1;39 double tmin = -6.*M_PI, tmax = -6.*M_PI; 40 //double tmin = M_PI-0.1, tmax = M_PI+0.1; 38 41 unsigned long N = 4; 39 42 bool only_test = false; … … 44 47 //--- Read arguments 45 48 char c; 46 while((c = getopt(narg,arg,"htp:n:v: ")) != -1) {49 while((c = getopt(narg,arg,"htp:n:v:x:")) != -1) { 47 50 switch (c) { 48 51 case 'n' : … … 55 58 sscanf(optarg,"%lf",&pr_test); 56 59 break; 60 case 'x' : 61 sscanf(optarg,"%lf,%lf,%lf",&dt,&tmin,&tmax); 62 break; 57 63 case 'v' : 58 sscanf(optarg,"%d,%lf ",&nvec,&vecmax);64 sscanf(optarg,"%d,%lf,%lf",&nvec,&vecmax,&veccent); 59 65 break; 60 66 case 'h' : 61 67 default : 62 cout<<"cmvsinxsx [-t] [-p eps_print] [-n N] [-v nv,(+-)vmax (rad)]"<<endl;68 cout<<"cmvsinxsx [-t] [-p eps_print] [-n N] [-v nv,(+-)vmax,vcent (rad)]"<<endl; 63 69 cout<<" [dt,tmin,tmax (rad)]"<<endl; 64 70 return -1; 65 } 66 } 67 if(optind<narg) sscanf(arg[optind],"%lf,%lf,%lf",&dt,&tmin,&tmax); 71 break; 72 } 73 } 74 75 if(N<=0) N=1; 76 // on calcule pour avoir 20 points par periode de sin(n*x) 77 if(dt<=0.) dt = 2.*M_PI/(20.*N); 68 78 69 79 cout<<"N="<<N<<" dt="<<dt<<" tmin="<<tmin<<" tmax="<<tmax<<" rad"<<endl; 70 80 cout<<"only_test="<<only_test<<" pr_test="<<pr_test<<endl; 71 81 if(vecmax<0.) vecmax *= -M_PI; 72 cout<<"nv="<<nvec<<" vmax="<<vecmax<<" -> ["<<-vecmax/2<<","<<vecmax/2<<"]"<<endl; 82 cout<<"nv="<<nvec<<" vmax="<<vecmax<<" vcent="<<veccent 83 <<" -> ["<<veccent-vecmax/2<<","<<veccent+vecmax/2<<"]"<<endl; 73 84 if(tmax<=tmin) return -1; 74 85 … … 83 94 double diffsx=0., diffsx2=0., diffsnx=0., diffsnx2=0.; 84 95 for(double t=tmin; t<tmax+dt/3.; t+=dt) { 85 xnt[0] = t;86 xnt[1] = sin(t);87 xnt[2] = sin(N*t);88 xnt[3] = SinXsX(t);89 xnt[4] = SinXsX_Sqr(t);90 xnt[5] = SinNXsX(t,N);91 xnt[6] = SinNXsX_Sqr(t,N);92 xnt[7] = SinXsX(t,true);93 xnt[8] = SinXsX_Sqr(t,true);94 xnt[9] = SinNXsX(t,N,true);96 xnt[0] = t; 97 xnt[1] = sin(t); 98 xnt[2] = sin(N*t); 99 xnt[3] = SinXsX(t); 100 xnt[4] = SinXsX_Sqr(t); 101 xnt[5] = SinNXsX(t,N); 102 xnt[6] = SinNXsX_Sqr(t,N); 103 xnt[7] = SinXsX(t,true); 104 xnt[8] = SinXsX_Sqr(t,true); 105 xnt[9] = SinNXsX(t,N,true); 95 106 xnt[10] = SinNXsX_Sqr(t,N,true); 96 107 if(!only_test) nt.Fill(xnt); … … 142 153 POutPersist pos("cmvsinxsx.ppf"); 143 154 if(!only_test) pos.PutObject(nt,"nt"); 144 if(vsx.Size()>0) pos.PutObject(vsx,"vsx");145 if(vsx2.Size()>0) pos.PutObject(vsx2,"vsx2");146 if(vsnx.Size()>0) pos.PutObject(vsnx,"vsnx");155 if(vsx.Size()>0) pos.PutObject(vsx,"vsx"); 156 if(vsx2.Size()>0) pos.PutObject(vsx2,"vsx2"); 157 if(vsnx.Size()>0) pos.PutObject(vsnx,"vsnx"); 147 158 if(vsnx2.Size()>0) pos.PutObject(vsnx2,"vsnx2"); 148 159 … … 154 165 155 166 zone 156 n/plot nt.s%t ! ! " connectpoints"157 n/plot nt.sn%t ! ! " connectpoints same red"158 159 #------- 160 zone 1 3 161 n/plot nt.sx%t ! ! " connectpoints"162 n/plot nt.asx%t ! ! " connectpoints same green"163 n/plot nt.sx-s/t%t fabs(t)>1e-15 ! " connectpoints"164 n/plot nt.sx-asx%t ! ! " connectpoints"165 166 #------- 167 zone 1 3 168 n/plot nt.sx2%t ! ! " connectpoints"169 n/plot nt.sx*sx%t ! ! "connectpoints same red"170 n/plot nt.asx2%t ! ! " connectpoints same green"171 n/plot nt.sx2-pow(s/t,2.)%t fabs(t)>1e-15 ! " connectpoints"172 n/plot nt.sx2-asx2%t ! ! " connectpoints"173 174 #------- 175 zone 1 3 176 n/plot nt.snx%t ! ! " connectpoints"177 n/plot nt.asnx%t ! ! " connectpoints same green"178 n/plot nt.snx-sn/s%t fabs(s)>1e-15 ! " connectpoints"179 n/plot nt.snx-asnx%t ! ! " connectpoints"180 181 #------- 182 zone 1 3 183 n/plot nt.snx2%t ! ! " connectpoints"184 n/plot nt.snx*snx%t ! ! "connectpoints same red"185 n/plot nt.asnx2%t ! ! " connectpoints same green"186 n/plot nt.snx2-pow(sn/s,2.)%t fabs(s)>1e-15 ! " connectpoints"187 n/plot nt.snx2-asnx2%t ! ! " connectpoints"167 n/plot nt.s%t ! ! "nsta connectpoints" 168 n/plot nt.sn%t ! ! "nsta connectpoints same red" 169 170 #------- 171 zone 1 3 172 n/plot nt.sx%t ! ! "nsta connectpoints" 173 n/plot nt.asx%t ! ! "nsta connectpoints same green" 174 n/plot nt.sx-s/t%t fabs(t)>1e-15 ! "nsta connectpoints" 175 n/plot nt.sx-asx%t ! ! "nsta connectpoints" 176 177 #------- 178 zone 1 3 179 n/plot nt.sx2%t ! ! "nsta connectpoints" 180 #n/plot nt.sx*sx%t ! ! "nsta connectpoints same red" 181 n/plot nt.asx2%t ! ! "nsta connectpoints same green" 182 n/plot nt.sx2-pow(s/t,2.)%t fabs(t)>1e-15 ! "nsta connectpoints" 183 n/plot nt.sx2-asx2%t ! ! "nsta connectpoints" 184 185 #------- 186 zone 1 3 187 n/plot nt.snx%t ! ! "nsta connectpoints" 188 n/plot nt.asnx%t ! ! "nsta connectpoints same green" 189 n/plot nt.snx-sn/s%t fabs(s)>1e-15 ! "nsta connectpoints" 190 n/plot nt.snx-asnx%t ! ! "nsta connectpoints" 191 192 #------- 193 zone 1 3 194 n/plot nt.snx2%t ! ! "nsta connectpoints" 195 #n/plot nt.snx*snx%t ! ! "nsta connectpoints same red" 196 n/plot nt.asnx2%t ! ! "nsta connectpoints same green" 197 n/plot nt.snx2-pow(sn/s,2.)%t fabs(s)>1e-15 ! "nsta connectpoints" 198 n/plot nt.snx2-asnx2%t ! ! "nsta connectpoints" 188 199 189 200 #------- … … 203 214 204 215 zone 205 n/plot fvsx.val%n ! ! "connectpoints" 206 n/plot fvsx2.val%n ! ! "connectpoints" 207 n/plot fvsnx.val%n ! ! "connectpoints" 208 n/plot fvsnx2.val%n ! ! "connectpoints" 216 n/plot fvsx.val%n ! ! "nsta connectpoints" 217 n/plot fvsx2.val%n ! ! "nsta connectpoints" 218 n/plot fvsnx.val%n ! ! "nsta connectpoints" 219 n/plot fvsnx2.val%n ! ! "nsta connectpoints" 220 221 zone 222 n/plot fvsx.log10(mod*mod)%n mod>0. ! "nsta connectpoints" 223 n/plot fvsx2.log10(mod*mod)%n mod>0. ! "nsta connectpoints" 224 n/plot fvsnx.log10(mod*mod)%n mod>0. ! "nsta connectpoints" 225 n/plot fvsnx2.log10(mod*mod)%n mod>0. ! "nsta connectpoints" 209 226 210 227 */ -
trunk/Cosmo/SimLSS/geneutils.cc
r3500 r3595 296 296 double SinXsX(double x,bool app) 297 297 // Calcul de sin(x)/x 298 // Approx: dernier terme x^6/(6*20*42) ~ 1e-13 -> x^2 ~ 1.7e-4 298 // Le Dl est en O[x]^10 (cad on va jusqu'au terme en x^8 compris) 299 // Approx: terme en x^6/(6*20*42) ~ 1e-13 -> x^2 ~ 1.7e-4 299 300 { 300 301 double x2 = x*x; 301 if(app || x2<1.7e-4) return 1. - x2/6.*(1. - x2/20.*(1. - x2/42.));302 if(app || x2<1.7e-4) return 1.-x2/6.*(1.-x2/20.*(1.-x2/42.*(1.-x2/72.))); 302 303 return sin(x)/x; 303 304 } … … 305 306 double SinXsX_Sqr(double x,bool app) 306 307 // Calcul de (sin(x)/x)^2 307 // Approx: dernier terme 2*x^6/(3*15*14) ~ 1e-13 -> x^2 ~ 6.8e-5 308 // Le Dl est en O[x]^10 (cad on va jusqu'au terme en x^8 compris) 309 // Approx: terme 2*x^6/(3*15*14) ~ 1e-13 -> x^2 ~ 6.8e-5 308 310 { 309 311 double x2 = x*x; 310 if(app || x2<6.8e-5) return 1. - x2/3.*(1. - 2.*x2/15.*(1. - x2/14.));312 if(app || x2<6.8e-5) return 1.-x2/3.*(1.-2.*x2/15.*(1.-x2/14.*(1.-2.*x2/45.))); 311 313 x2 = sin(x)/x; 312 314 return x2*x2; … … 343 345 // Calcul de [sin(N*x)/sin(x)]^2 avec N entier positif 344 346 // ATTENTION: cf remarque pour N entier dans SinNXsX 347 // maximum de la fonction: N^2 345 348 // Approx: dernier terme x^4*2*N^4/45 ~ 1e-13 -> x^2 ~ 1.5e-6/N^2 346 349 { … … 349 352 if(app || sx*sx<1.5e-6/N2) { 350 353 double x2 = asin(sx); x2 *= x2; 351 return N2*(1. - (N-1.)*(N+1.)/3.*x2*(1. - (2.*N2-3.)/15.*x2)); 354 //return N2*(1.-(N*N-1.)/3.*x2); 355 return N2*(1.-(N-1.)*(N+1.)/3.*x2*(1.-(2.*N2-3.)/15.*x2)); 352 356 } 353 357 sx = sin((double)N*x)/sx;
Note:
See TracChangeset
for help on using the changeset viewer.