#include #include #include #include #include #include #define ACCL1 #define ACCL2 #ifdef ACCL1 #define ACCL0 #endif #ifdef ACCL2 #define ACCL0 #endif namespace ppc{ using namespace std; struct setprc{ short store; setprc(){ short byte=127, end; __asm__("fstcw %0\nfldcw %1\nfstcw %2"::"m" (store), "m" (byte), "m" (end)); // cerr< oms; #ifdef ACCL2 static const int cx=10, cy=10, cz=10; int cn[3]={cx, cy, cz}; vector cells[cx][cy][cz]; float cl[3], ch[3], crst[3]; #endif void load(){ ifstream inFile; inFile.open("geo-f2k", ifstream::in); if(!inFile.fail()){ DOM dom; string mbid; int om, str; unsigned long long omid; while(inFile>>mbid>>hex>>omid>>dec>>dom.r[0]>>dom.r[1]>>dom.r[2]>>str>>om) if(str>0 && om>=1 && om<=60){ dom.r[2]+=zoff; dom.t.n.dom=om; dom.t.n.str=str; oms.push_back(dom); } inFile.close(); } #ifdef ACCL2 for(int i=0; ich[m]) ch[m]=oms[n].r[m]; } for(int m=0; m<3; m++){ double diff=ch[m]-cl[m]; if(diff=cn[m]){ cerr<<"Error in cell initialization"<coschr, m.w->sinchr); } void rotate(float cs, float si){ float u[3]; { float p1[3], p2[3]; { int i0=0; float n0=n[0]; for(int i=1; i<3; i++) if(abs(n[i])>abs(n0)){ i0=i; n0=n[i]; } int i1=(i0+1)%3, i2=(i0+2)%3; float n1=n[i1], n2=n[i2], nq=n0*n0; float r1=1/sqrtf(nq+n1*n1), r2=1/sqrtf(nq+n2*n2); p1[i0]=-n1*r1; p1[i1]=n0*r1; p1[i2]=0; p2[i0]=-n2*r2; p2[i1]=0; p2[i2]=n0*r2; } { float q1[3], q2[3], r1=0, r2=0; for(int i=0; i<3; i++){ float a1=p1[i]-p2[i]; q1[i]=a1; r1+=a1*a1; float a2=p1[i]+p2[i]; q2[i]=a2; r2+=a2*a2; } r1=1/sqrtf(r1); r2=1/sqrtf(r2); for(int i=0; i<3; i++){ p1[i]=q1[i]*r1; p2[i]=q2[i]*r2; } } { float zi=xrnd(); zi*=2*M_PI; float px=cosf(zi), py=sinf(zi); for(int i=0; i<3; i++) u[i]=px*p1[i]+py*p2[i]; } } { float r=0; for(int i=0; i<3; i++){ float a=n[i]*cs+u[i]*si; n[i]=a; r+=a*a; } { r=1/sqrtf(r); for(int i=0; i<3; i++) n[i]*=r; } } } void rotate(){ float xi=xrnd(); xi=2*xi-1; float g=m.g; if(g!=0){ float g2=g*g; float ga=(1-g2)/(1+g*xi); xi=(1+g2-ga*ga)/(2*g); } if(xi>1) xi=1; else if(xi<-1) xi=-1; float si=sqrtf(1-xi*xi); rotate(xi, si); } void advance(float a){ t+=a*m.w->ocm; for(int i=0; i<3; i++) r[i]+=n[i]*a; } void propagate(){ float TOT=-logf(xrnd()); while(true){ float SCA=-logf(xrnd()); float sca=m.sX(SCA, r[2], n[2]); float tot=m.aX(TOT, r[2], n[2]); if(tot0){ dn[m]=ini; dx[m]=fin; } else{ dn[m]=fin; dx[m]=ini; } dn[m]-=R; dx[m]+=R; } #endif #ifdef ACCL2 int xl[3], xh[3]; for(int m=0; m<3; m++){ xl[m]=min(max((int) lroundf((dn[m]-cl[m])*crst[m]), 0), cn[m]); xh[m]=max(min((int) lroundf((dx[m]-cl[m])*crst[m]), cn[m]-1), -1); } for(int i=xl[0]; i<=xh[0]; i++) for(int j=xl[1]; j<=xh[1]; j++) for(int k=xl[2]; k<=xh[2]; k++) for(int l=0; ldx[i]){ pass=true; break; } if(pass) continue; #endif { float b=0, c=0; for(int i=0; i<3; i++){ float dr=om.r[i]-r[i]; b+=n[i]*dr; c+=dr*dr; } c-=R*R; float D=b*b-c, h=-1; if(D>0) h=b-sqrtf(D); if(h>0 && h1) str=atoi(arg_a[1]); if(arg_c>2) dom=atoi(arg_a[2]); if(arg_c>3) num=(unsigned long long) atof(arg_a[3]); if(arg_c>4) seed=atoi(arg_a[4]); srand(1+seed); flasher(str, dom, num); } }